Skip to content

Commit 729181c

Browse files
authored
test: migrate tailwind + pug test from Vite repo (#224)
1 parent ff68ed3 commit 729181c

10 files changed

+412
-118
lines changed

playground/tailwind/App.vue

+7
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>

playground/tailwind/PugTemplate.vue

+3
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>
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/index.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

playground/tailwind/index.html

+9
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>

playground/tailwind/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@vitejs/test-tailwind",
3+
"private": true,
4+
"version": "0.0.0",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"autoprefixer": "^10.4.14",
13+
"tailwindcss": "^3.3.3",
14+
"vue": "^3.3.4",
15+
"vue-router": "^4.2.4"
16+
},
17+
"devDependencies": {
18+
"@vitejs/plugin-vue": "workspace:*",
19+
"ts-node": "^10.9.1"
20+
}
21+
}

playground/tailwind/postcss.config.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// postcss.config.ts
2+
module.exports = {
3+
plugins: {
4+
tailwindcss: { config: __dirname + '/tailwind.config.js' },
5+
autoprefixer: {},
6+
},
7+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('tailwindcss').Config} */
2+
3+
module.exports = {
4+
content: [__dirname + '/**/*.vue'],
5+
theme: {
6+
extend: {},
7+
},
8+
variants: {
9+
extend: {},
10+
},
11+
plugins: [],
12+
}

playground/tailwind/vite.config.ts

+10
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)