File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,11 @@ export default function svelte(options = {}) {
184
184
const compiled = compile (
185
185
code ,
186
186
Object . assign ( { } , {
187
- onwarn : warning => this . warn ( warning ) ,
187
+ onwarn : warning => {
188
+ // TODO replace this with warning.code, post sveltejs/svelte#824
189
+ if ( options . css === false && warning . message === 'Unused CSS selector' ) return ;
190
+ this . warn ( warning ) ;
191
+ } ,
188
192
onerror : error => this . error ( error )
189
193
} , fixedOptions , {
190
194
name : capitalize ( sanitize ( id ) ) ,
Original file line number Diff line number Diff line change @@ -112,4 +112,24 @@ describe('rollup-plugin-svelte', () => {
112
112
} ) ;
113
113
} ) ;
114
114
} ) ;
115
+
116
+ it ( 'squelches CSS warnings if css: false' , ( ) => {
117
+ const { transform } = plugin ( {
118
+ css : false ,
119
+ cascade : false
120
+ } ) ;
121
+
122
+ transform . call ( {
123
+ warn : warning => {
124
+ throw new Error ( warning . message ) ;
125
+ }
126
+ } , `
127
+ <div></div>
128
+ <style>
129
+ .unused {
130
+ color: red;
131
+ }
132
+ </style>
133
+ ` , 'test.html' ) ;
134
+ } ) ;
115
135
} ) ;
You can’t perform that action at this time.
0 commit comments