File tree 1 file changed +70
-0
lines changed
1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change 71
71
await fs . expectFileToContain ( files [ 0 ] [ 0 ] , [ '.bar{' ] )
72
72
} ,
73
73
)
74
+
75
+ test (
76
+ 'error when using `@apply` without `@reference`' ,
77
+ {
78
+ fs : {
79
+ 'package.json' : json `
80
+ {
81
+ "type": "module",
82
+ "dependencies": {
83
+ "vue": "^3.4.37",
84
+ "tailwindcss": "workspace:^"
85
+ },
86
+ "devDependencies": {
87
+ "@vitejs/plugin-vue": "^5.1.2",
88
+ "@tailwindcss/vite": "workspace:^",
89
+ "vite": "^6"
90
+ }
91
+ }
92
+ ` ,
93
+ 'vite.config.ts' : ts `
94
+ import { defineConfig } from 'vite'
95
+ import vue from '@vitejs/plugin-vue'
96
+ import tailwindcss from '@tailwindcss/vite'
97
+
98
+ export default defineConfig({
99
+ plugins: [vue(), tailwindcss()],
100
+ })
101
+ ` ,
102
+ 'index.html' : html `
103
+ <!doctype html>
104
+ < html >
105
+ < body >
106
+ < div id ="app "> </ div >
107
+ < script type ="module " src ="./src/main.ts "> </ script >
108
+ </ body >
109
+ </ html >
110
+ ` ,
111
+ 'src/main.ts' : ts `
112
+ import { createApp } from 'vue'
113
+ import App from './App.vue'
114
+
115
+ createApp(App).mount('#app')
116
+ ` ,
117
+ 'src/App.vue' : html `
118
+ < template >
119
+ < div class ="foo "> Hello Vue!</ div >
120
+ </ template >
121
+
122
+ < style >
123
+ .foo {
124
+ @apply text-red-500;
125
+ }
126
+ </ style >
127
+ ` ,
128
+ } ,
129
+ } ,
130
+ async ( { exec, expect } ) => {
131
+ expect . assertions ( 1 )
132
+
133
+ try {
134
+ await exec ( 'pnpm vite build' )
135
+ } catch ( error ) {
136
+ let [ , message ] = / e r r o r d u r i n g b u i l d : ( [ \s \S ] * ?) f i l e : / g. exec ( error . message ) ?? [ ]
137
+ expect ( message . trim ( ) ) . toMatchInlineSnapshot ( `
138
+ "[@tailwindcss/vite:generate:build] Cannot apply unknown utility class: \`text-red-500\`.
139
+ It looks like you are missing a \`@reference "app.css"\` or \`@import "tailwindcss";\`"
140
+ ` )
141
+ }
142
+ } ,
143
+ )
You can’t perform that action at this time.
0 commit comments