Skip to content

Commit

Permalink
test: migrate tailwind + pug test from Vite repo (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 14, 2023
1 parent ff68ed3 commit 729181c
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 118 deletions.
7 changes: 7 additions & 0 deletions playground/tailwind/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/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/__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/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/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>
21 changes: 21 additions & 0 deletions playground/tailwind/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@vitejs/test-tailwind",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview"
},
"dependencies": {
"autoprefixer": "^10.4.14",
"tailwindcss": "^3.3.3",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "workspace:*",
"ts-node": "^10.9.1"
}
}
7 changes: 7 additions & 0 deletions playground/tailwind/postcss.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// postcss.config.ts
module.exports = {
plugins: {
tailwindcss: { config: __dirname + '/tailwind.config.js' },
autoprefixer: {},
},
}
12 changes: 12 additions & 0 deletions playground/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */

module.exports = {
content: [__dirname + '/**/*.vue'],
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
10 changes: 10 additions & 0 deletions playground/tailwind/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,
},
})

0 comments on commit 729181c

Please sign in to comment.