This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -56,14 +56,19 @@ export default (options?: Options): LoaderPlugin => {
56
56
await loading
57
57
}
58
58
const pcss = ( await postcss ! . process ( ( new TextDecoder ) . decode ( content ) ) . async ( ) ) . content
59
- const mini = Deno . env . get ( 'BUILD_MODE' ) === 'production'
60
- const css = mini ? cleanCSS . minify ( pcss ) . styles : pcss
61
- const js = [
62
- 'import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"' ,
63
- `applyCSS(${ JSON . stringify ( url ) } , ${ JSON . stringify ( css ) } )`
64
- ] . join ( '\n' )
59
+ const css = Deno . env . get ( 'BUILD_MODE' ) === 'production' ? cleanCSS . minify ( pcss ) . styles : pcss
60
+ if ( url . startsWith ( '#inline-style-' ) ) {
61
+ return {
62
+ code : css ,
63
+ type : 'css' ,
64
+ map : undefined
65
+ }
66
+ }
65
67
return {
66
- code : js ,
68
+ code : [
69
+ 'import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"' ,
70
+ `applyCSS(${ JSON . stringify ( url ) } , ${ JSON . stringify ( css ) } )`
71
+ ] . join ( '\n' ) ,
67
72
map : undefined // todo: generate map
68
73
}
69
74
}
Original file line number Diff line number Diff line change @@ -13,6 +13,16 @@ Deno.test('css loader', async () => {
13
13
assertEquals ( code , 'import { applyCSS } from "https://deno.land/x/aleph/framework/core/style.ts"\napplyCSS("/test.css", "h1 { font-size: 18px; }")' )
14
14
} )
15
15
16
+ Deno . test ( 'css loader for inline style' , async ( ) => {
17
+ const loader = cssLoader ( )
18
+ const { code, type } = await loader . transform ( {
19
+ url : '#inline-style-{}' ,
20
+ content : ( new TextEncoder ) . encode ( 'h1 { font-size: 18px; }' ) ,
21
+ } )
22
+ assertEquals ( code , 'h1 { font-size: 18px; }' )
23
+ assertEquals ( type , 'css' )
24
+ } )
25
+
16
26
Deno . test ( 'css loader in production mode' , async ( ) => {
17
27
Deno . env . set ( 'BUILD_MODE' , 'production' )
18
28
You can’t perform that action at this time.
0 commit comments