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 +39
-11
lines changed Expand file tree Collapse file tree 2 files changed +39
-11
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,29 @@ export default {
55 test : / .( s a s s | s c s s ) $ / ,
66 acceptHMR : true ,
77 transform ( content : Uint8Array , path : string ) {
8- const ret = renderSync ( {
9- file : path ,
10- data : ( new TextDecoder ) . decode ( content ) ,
11- sourceMap : true
12- } )
13- return {
14- code : ( new TextDecoder ) . decode ( ret . css ) ,
15- map : ret . map ? ( new TextDecoder ) . decode ( ret . map ) : undefined ,
16- loader : 'css'
8+ if ( path . endsWith ( '.sass' ) ) {
9+ const ret = renderSync ( {
10+ file : path ,
11+ data : ( new TextDecoder ) . decode ( content ) ,
12+ sourceMap : true ,
13+ indentedSyntax : true
14+ } )
15+ return {
16+ code : ( new TextDecoder ) . decode ( ret . css ) ,
17+ map : ret . map ? ( new TextDecoder ) . decode ( ret . map ) : undefined ,
18+ loader : 'css'
19+ }
20+ } else {
21+ const ret = renderSync ( {
22+ file : path ,
23+ data : ( new TextDecoder ) . decode ( content ) ,
24+ sourceMap : true
25+ } )
26+ return {
27+ code : ( new TextDecoder ) . decode ( ret . css ) ,
28+ map : ret . map ? ( new TextDecoder ) . decode ( ret . map ) : undefined ,
29+ loader : 'css'
30+ }
1731 }
1832 }
1933}
Original file line number Diff line number Diff line change 11import { assertEquals } from 'https://deno.land/std/testing/asserts.ts' ;
22import plugin from './sass.ts' ;
33
4- Deno . test ( 'project sass loader plugin' , ( ) => {
4+ Deno . test ( 'project scss loader plugin' , ( ) => {
55 Object . assign ( window , {
66 location : {
77 href : 'https://localhost/'
88 }
99 } )
1010 const { code, loader } = plugin . transform (
1111 ( new TextEncoder ) . encode ( '$someVar: 123px; .some-selector { width: $someVar; }' ) ,
12- 'test.sass '
12+ 'test.scss '
1313 )
1414 assertEquals ( plugin . test . test ( 'test.sass' ) , true )
1515 assertEquals ( plugin . test . test ( 'test.scss' ) , true )
1616 assertEquals ( plugin . acceptHMR , true )
1717 assertEquals ( code , '.some-selector {\n width: 123px;\n}' )
1818 assertEquals ( loader , 'css' )
1919} )
20+
21+ Deno . test ( 'project sass loader plugin' , ( ) => {
22+ Object . assign ( window , {
23+ location : {
24+ href : 'https://localhost/'
25+ }
26+ } )
27+ const { code, loader } = plugin . transform (
28+ ( new TextEncoder ) . encode ( '$someVar: 123px\n.some-selector\n width: 123px' ) ,
29+ 'test.sass'
30+ )
31+ assertEquals ( code , '.some-selector {\n width: 123px;\n}' )
32+ assertEquals ( loader , 'css' )
33+ } )
You can’t perform that action at this time.
0 commit comments