This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change 1
- import { renderSync } from 'https://esm.sh/[email protected] '
1
+ import { Options , renderSync } from 'https://esm.sh/[email protected] '
2
2
3
- export default {
3
+ const defaultOptions = {
4
4
name : 'sass-loader' ,
5
5
test : / .( s a s s | s c s s ) $ / ,
6
6
acceptHMR : true ,
@@ -31,3 +31,41 @@ export default {
31
31
}
32
32
}
33
33
}
34
+
35
+ let plugin : any = ( opts : Options ) => ( {
36
+ name : 'sass-loader' ,
37
+ test : / .( s a s s | s c s s ) $ / ,
38
+ acceptHMR : true ,
39
+ transform ( content : Uint8Array , path : string ) {
40
+ if ( path . endsWith ( '.sass' ) ) {
41
+ const ret = renderSync ( {
42
+ ...opts ,
43
+ file : path ,
44
+ data : ( new TextDecoder ) . decode ( content ) ,
45
+ sourceMap : true ,
46
+ indentedSyntax : true
47
+ } )
48
+ return {
49
+ code : ( new TextDecoder ) . decode ( ret . css ) ,
50
+ map : ret . map ? ( new TextDecoder ) . decode ( ret . map ) : undefined ,
51
+ loader : 'css'
52
+ }
53
+ } else {
54
+ const ret = renderSync ( {
55
+ ...opts ,
56
+ file : path ,
57
+ data : ( new TextDecoder ) . decode ( content ) ,
58
+ sourceMap : true
59
+ } )
60
+ return {
61
+ code : ( new TextDecoder ) . decode ( ret . css ) ,
62
+ map : ret . map ? ( new TextDecoder ) . decode ( ret . map ) : undefined ,
63
+ loader : 'css'
64
+ }
65
+ }
66
+ }
67
+ } )
68
+
69
+ plugin = { ...plugin , ...defaultOptions }
70
+
71
+ export default plugin ;
You can’t perform that action at this time.
0 commit comments