Skip to content

Commit b467fa8

Browse files
committed
test: add tailwind v3 playground
1 parent 82e7714 commit b467fa8

File tree

9 files changed

+105
-0
lines changed

9 files changed

+105
-0
lines changed

playground/tailwind-v3/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<PugTemplate />
3+
</template>
4+
5+
<script setup lang="ts">
6+
import PugTemplate from './PugTemplate.vue'
7+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template lang="pug">
2+
.bg-red-400.pug Pug template
3+
</template>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, test } from 'vitest'
2+
import {
3+
editFile,
4+
getBgColor,
5+
isServe,
6+
page,
7+
untilBrowserLogAfter,
8+
untilUpdated,
9+
} from '~utils'
10+
11+
test.runIf(isServe)('regenerate CSS and HMR (pug template)', async () => {
12+
const el = await page.$('.pug')
13+
expect(await getBgColor(el)).toBe('rgb(248, 113, 113)')
14+
15+
await untilBrowserLogAfter(
16+
() =>
17+
editFile('PugTemplate.vue', (code) =>
18+
code.replace('bg-red-400', 'bg-red-600'),
19+
),
20+
[
21+
'[vite] css hot updated: /index.css',
22+
'[vite] hot updated: /PugTemplate.vue?vue&type=template&lang.js',
23+
],
24+
false,
25+
)
26+
await untilUpdated(() => getBgColor(el), 'rgb(220, 38, 38)')
27+
})

playground/tailwind-v3/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

playground/tailwind-v3/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<link rel="stylesheet" href="./index.css" />
2+
3+
<div id="app"></div>
4+
<script type="module">
5+
import { createApp } from 'vue'
6+
import App from './App.vue'
7+
8+
createApp(App).mount('#app')
9+
</script>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@vitejs/test-tailwind-v3",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"autoprefixer": "^10.4.21",
14+
"tailwindcss": "^3.4.17",
15+
"vue": "catalog:",
16+
"vue-router": "catalog:"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^22.14.1",
20+
"@vitejs/plugin-vue": "workspace:*",
21+
"ts-node": "^10.9.2"
22+
}
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: { config: __dirname + '/tailwind.config.js' },
4+
autoprefixer: {},
5+
},
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { fileURLToPath } from 'node:url'
2+
import { dirname } from 'node:path'
3+
4+
const __filename = fileURLToPath(import.meta.url)
5+
const __dirname = dirname(__filename)
6+
7+
/** @type {import('tailwindcss').Config} */
8+
export default {
9+
content: [__dirname + '/**/*.vue'],
10+
theme: {
11+
extend: {},
12+
},
13+
variants: {
14+
extend: {},
15+
},
16+
plugins: [],
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
3+
4+
export default defineConfig({
5+
plugins: [vue()],
6+
build: {
7+
// to make tests faster
8+
minify: false,
9+
},
10+
})

0 commit comments

Comments
 (0)