File tree Expand file tree Collapse file tree 12 files changed +150
-19
lines changed
playground/css/postcss-caching Expand file tree Collapse file tree 12 files changed +150
-19
lines changed Original file line number Diff line number Diff line change
1
+ .postcss-a {
2
+ color : pink;
3
+ }
Original file line number Diff line number Diff line change
1
+ < div class ="wrapper ">
2
+ < h1 > CSS</ h1 >
3
+
4
+ < p > Imported css string:</ p >
5
+ < pre class ="imported-css "> </ pre >
6
+
7
+ < p class ="postcss-a "> This should be blue</ p >
8
+
9
+ < p class ="postcss-b "> This should be black</ p >
10
+ </ div >
11
+
12
+ < script type ="module " src ="./main.js "> </ script >
Original file line number Diff line number Diff line change
1
+ import css from './imported.css'
2
+ text ( '.imported-css' , css )
3
+
4
+ function text ( el , text ) {
5
+ document . querySelector ( el ) . textContent = text
6
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " blue-app" ,
3
+ "private" : true ,
4
+ "version" : " 0.0.0" ,
5
+ "scripts" : {
6
+ "dev" : " vite" ,
7
+ "build" : " vite build" ,
8
+ "debug" : " node --inspect-brk ../../vite/bin/vite" ,
9
+ "serve" : " vite preview"
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ plugins : [ replacePinkWithBlue ]
3
+ }
4
+
5
+ function replacePinkWithBlue ( ) {
6
+ return {
7
+ postcssPlugin : 'replace-pink-with-blue' ,
8
+ Declaration ( decl ) {
9
+ if ( decl . value === 'pink' ) {
10
+ decl . value = 'blue'
11
+ }
12
+ }
13
+ }
14
+ }
15
+ replacePinkWithBlue . postcss = true
Original file line number Diff line number Diff line change
1
+ import { getColor } from '../../testUtils'
2
+ import { createServer } from 'vite'
3
+ import path from 'path'
4
+
5
+ test ( 'postcss config' , async ( ) => {
6
+ const port = 5005
7
+ const blueAppDir = path . join ( __dirname , 'blue-app' )
8
+ const greenAppDir = path . join ( __dirname , 'green-app' )
9
+
10
+ process . chdir ( blueAppDir )
11
+ const blueApp = await createServer ( )
12
+ await blueApp . listen ( port )
13
+ await page . goto ( `http://localhost:${ port } ` )
14
+ const blueA = await page . $ ( '.postcss-a' )
15
+ expect ( await getColor ( blueA ) ) . toBe ( 'blue' )
16
+ const blueB = await page . $ ( '.postcss-b' )
17
+ expect ( await getColor ( blueB ) ) . toBe ( 'black' )
18
+ await blueApp . close ( )
19
+
20
+ process . chdir ( greenAppDir )
21
+ const greenApp = await createServer ( )
22
+ await greenApp . listen ( port )
23
+ await page . goto ( `http://localhost:${ port } ` )
24
+ const greenA = await page . $ ( '.postcss-a' )
25
+ expect ( await getColor ( greenA ) ) . toBe ( 'black' )
26
+ const greenB = await page . $ ( '.postcss-b' )
27
+ expect ( await getColor ( greenB ) ) . toBe ( 'green' )
28
+ await greenApp . close ( )
29
+ } )
Original file line number Diff line number Diff line change
1
+ .postcss-b {
2
+ color : pink;
3
+ }
Original file line number Diff line number Diff line change
1
+ < div class ="wrapper ">
2
+ < h1 > CSS</ h1 >
3
+
4
+ < p > Imported css string:</ p >
5
+ < pre class ="imported-css "> </ pre >
6
+
7
+ < p class ="postcss-a "> This should be black</ p >
8
+
9
+ < p class ="postcss-b "> This should be green</ p >
10
+ </ div >
11
+
12
+ < script type ="module " src ="./main.js "> </ script >
Original file line number Diff line number Diff line change
1
+ import css from './imported.css'
2
+ text ( '.imported-css' , css )
3
+
4
+ function text ( el , text ) {
5
+ document . querySelector ( el ) . textContent = text
6
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " green-app" ,
3
+ "private" : true ,
4
+ "version" : " 0.0.0" ,
5
+ "scripts" : {
6
+ "dev" : " vite" ,
7
+ "build" : " vite build" ,
8
+ "debug" : " node --inspect-brk ../../vite/bin/vite" ,
9
+ "serve" : " vite preview"
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments