Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions playground/tailwind-v3/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<PugTemplate />
</template>

<script setup lang="ts">
import PugTemplate from './PugTemplate.vue'
</script>
3 changes: 3 additions & 0 deletions playground/tailwind-v3/PugTemplate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template lang="pug">
.bg-red-400.pug Pug template
</template>
27 changes: 27 additions & 0 deletions playground/tailwind-v3/__tests__/tailwind.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect, test } from 'vitest'
import {
editFile,
getBgColor,
isServe,
page,
untilBrowserLogAfter,
untilUpdated,
} from '~utils'

test.runIf(isServe)('regenerate CSS and HMR (pug template)', async () => {
const el = await page.$('.pug')
expect(await getBgColor(el)).toBe('rgb(248, 113, 113)')

await untilBrowserLogAfter(
() =>
editFile('PugTemplate.vue', (code) =>
code.replace('bg-red-400', 'bg-red-600'),
),
[
'[vite] css hot updated: /index.css',
'[vite] hot updated: /PugTemplate.vue?vue&type=template&lang.js',
],
false,
)
await untilUpdated(() => getBgColor(el), 'rgb(220, 38, 38)')
})
3 changes: 3 additions & 0 deletions playground/tailwind-v3/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
9 changes: 9 additions & 0 deletions playground/tailwind-v3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<link rel="stylesheet" href="./index.css" />

<div id="app"></div>
<script type="module">
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')
</script>
23 changes: 23 additions & 0 deletions playground/tailwind-v3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@vitejs/test-tailwind-v3",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview"
},
"dependencies": {
"autoprefixer": "^10.4.21",
"tailwindcss": "^3.4.17",
"vue": "catalog:",
"vue-router": "catalog:"
},
"devDependencies": {
"@types/node": "^22.14.1",
"@vitejs/plugin-vue": "workspace:*",
"ts-node": "^10.9.2"
}
}
10 changes: 10 additions & 0 deletions playground/tailwind-v3/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
build: {
// to make tests faster
minify: false,
},
})
4 changes: 2 additions & 2 deletions playground/tailwind/__tests__/tailwind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

test.runIf(isServe)('regenerate CSS and HMR (pug template)', async () => {
const el = await page.$('.pug')
expect(await getBgColor(el)).toBe('rgb(248, 113, 113)')
expect(await getBgColor(el)).toBe('oklch(0.704 0.191 22.216)')

await untilBrowserLogAfter(
() =>
Expand All @@ -23,5 +23,5 @@ test.runIf(isServe)('regenerate CSS and HMR (pug template)', async () => {
],
false,
)
await untilUpdated(() => getBgColor(el), 'rgb(220, 38, 38)')
await untilUpdated(() => getBgColor(el), 'oklch(0.577 0.245 27.325)')
})
4 changes: 1 addition & 3 deletions playground/tailwind/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import 'tailwindcss';
7 changes: 3 additions & 4 deletions playground/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
"preview": "vite preview"
},
"dependencies": {
"autoprefixer": "^10.4.21",
"tailwindcss": "^3.4.17",
"@tailwindcss/vite": "^4.1.4",
"tailwindcss": "^4.1.4",
"vue": "catalog:",
"vue-router": "catalog:"
},
"devDependencies": {
"@types/node": "^22.14.1",
"@vitejs/plugin-vue": "workspace:*",
"ts-node": "^10.9.2"
"@vitejs/plugin-vue": "workspace:*"
}
}
3 changes: 2 additions & 1 deletion playground/tailwind/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwind from '@tailwindcss/vite'

export default defineConfig({
plugins: [vue()],
plugins: [vue(), tailwind()],
build: {
// to make tests faster
minify: false,
Expand Down
5 changes: 2 additions & 3 deletions playground/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function componentToHex(c: number): string {
return hex.length === 1 ? '0' + hex : hex
}

function rgbToHex(rgb: string): string {
function rgbToHex(rgb: string): string | undefined {
const match = rgb.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/)
if (match) {
const [_, rs, gs, bs] = match
Expand All @@ -63,9 +63,8 @@ function rgbToHex(rgb: string): string {
componentToHex(parseInt(gs, 10)) +
componentToHex(parseInt(bs, 10))
)
} else {
return '#000000'
}
return undefined
}

const timeout = (n: number) => new Promise((r) => setTimeout(r, n))
Expand Down
2 changes: 1 addition & 1 deletion playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"allowJs": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "Node",
"moduleResolution": "bundler",
"skipLibCheck": true,
"noUnusedLocals": true,
"jsx": "preserve",
Expand Down
Loading