File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // @ts -ignore upstream issue https://github.com/denoland/deno/issues/30560
2+ import "./css_styles.css" ;
3+
4+ export default function Page ( ) {
5+ return (
6+ < div >
7+ < div class = "route" >
8+ < h1 > red text</ h1 >
9+ </ div >
10+ </ div >
11+ ) ;
12+ }
Original file line number Diff line number Diff line change 1+ h1 {
2+ color : red;
3+ }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ export function devServer(): Plugin[] {
8181 url . pathname !== "/__inspect" &&
8282 res . headers . get ( "Content-Type" ) ?. includes ( "text/html" )
8383 ) {
84- const collected = await collectCss2 (
84+ const collected = await collectCss (
8585 "fresh:client-entry" ,
8686 server . environments . client ,
8787 ) ;
@@ -132,7 +132,7 @@ export function devServer(): Plugin[] {
132132 ] ;
133133}
134134
135- async function collectCss2 (
135+ async function collectCss (
136136 id : string ,
137137 env : DevEnvironment ,
138138) {
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
351351 } ,
352352 transform : {
353353 filter : {
354- id : / \. m o d u l e \. ( c s s | l e s s | s a s s ) ( \? .* ) ? $ / ,
354+ id : / \. ( c s s | l e s s | s a s s | s c s s ) ( \? .* ) ? $ / ,
355355 } ,
356356 handler ( _code , id , _options ) {
357357 if ( server ) {
Original file line number Diff line number Diff line change 11import { expect } from "@std/expect" ;
2- import { waitForText , withBrowser } from "../../fresh/tests/test_utils.tsx" ;
2+ import {
3+ waitFor ,
4+ waitForText ,
5+ withBrowser ,
6+ } from "../../fresh/tests/test_utils.tsx" ;
37import {
48 buildVite ,
59 DEMO_DIR ,
@@ -383,6 +387,33 @@ Deno.test({
383387 sanitizeResources : false ,
384388} ) ;
385389
390+ Deno . test ( {
391+ name : "vite build - route css import" ,
392+ fn : async ( ) => {
393+ await launchProd (
394+ { cwd : viteResult . tmp } ,
395+ async ( address ) => {
396+ await withBrowser ( async ( page ) => {
397+ await page . goto ( `${ address } /tests/css` , {
398+ waitUntil : "networkidle2" ,
399+ } ) ;
400+
401+ await waitFor ( async ( ) => {
402+ const color = await page
403+ . locator ( "h1" )
404+ // deno-lint-ignore no-explicit-any
405+ . evaluate ( ( el ) => window . getComputedStyle ( el as any ) . color ) ;
406+ expect ( color ) . toEqual ( "rgb(255, 0, 0)" ) ;
407+ return true ;
408+ } ) ;
409+ } ) ;
410+ } ,
411+ ) ;
412+ } ,
413+ sanitizeOps : false ,
414+ sanitizeResources : false ,
415+ } ) ;
416+
386417Deno . test ( {
387418 name : "vite build - remote island" ,
388419 fn : async ( ) => {
Original file line number Diff line number Diff line change @@ -306,6 +306,28 @@ Deno.test({
306306 sanitizeOps : false ,
307307} ) ;
308308
309+ Deno . test ( {
310+ name : "vite dev - route css import" ,
311+ fn : async ( ) => {
312+ await withBrowser ( async ( page ) => {
313+ await page . goto ( `${ demoServer . address ( ) } /tests/css` , {
314+ waitUntil : "networkidle2" ,
315+ } ) ;
316+
317+ await waitFor ( async ( ) => {
318+ const color = await page
319+ . locator ( "h1" )
320+ // deno-lint-ignore no-explicit-any
321+ . evaluate ( ( el ) => window . getComputedStyle ( el as any ) . color ) ;
322+ expect ( color ) . toEqual ( "rgb(255, 0, 0)" ) ;
323+ return true ;
324+ } ) ;
325+ } ) ;
326+ } ,
327+ sanitizeResources : false ,
328+ sanitizeOps : false ,
329+ } ) ;
330+
309331Deno . test ( {
310332 name : "vite dev - remote island" ,
311333 fn : async ( ) => {
You can’t perform that action at this time.
0 commit comments