Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate tailwind + pug test from Vite repo #224

Merged
merged 1 commit into from
Aug 14, 2023
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/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,
},
})
Loading