File tree Expand file tree Collapse file tree
test/configCases/css/export-type-style-ignore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " webpack " : patch
3+ ---
4+
5+ Fix crash when a CSS module with ` exportType: "style" ` imports an ignored stylesheet.
Original file line number Diff line number Diff line change @@ -851,6 +851,7 @@ class CssGenerator extends Generator {
851851 const depModule = /** @type {CssModule & BuiltCssModule } */ (
852852 moduleGraph . getModule ( dep )
853853 ) ;
854+ if ( ! depModule ) continue ;
854855 if ( concatenationScope && concatenationScope . isModuleInScope ( depModule ) ) {
855856 continue ;
856857 }
Original file line number Diff line number Diff line change 1+ import "./style.css" ;
2+
3+ it ( "should compile and inject styles even when @import is ignored" , ( ) => {
4+ const styles = Array . from ( document . getElementsByTagName ( "style" ) ) ;
5+ expect ( styles . some ( s => s . textContent . includes ( ".test" ) ) ) . toBe ( true ) ;
6+ } ) ;
Original file line number Diff line number Diff line change 1+ @import "./ignored.css" ;
2+
3+ . test {
4+ color : green;
5+ }
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ const webpack = require ( "../../../../" ) ;
4+
5+ /** @type {import("../../../../").Configuration } */
6+ module . exports = {
7+ target : "web" ,
8+ mode : "development" ,
9+ module : {
10+ rules : [
11+ {
12+ test : / \. c s s $ / ,
13+ type : "css/auto" ,
14+ parser : {
15+ exportType : "style"
16+ }
17+ }
18+ ]
19+ } ,
20+ experiments : {
21+ css : true
22+ } ,
23+ plugins : [
24+ new webpack . IgnorePlugin ( {
25+ resourceRegExp : / i g n o r e d \. c s s $ /
26+ } )
27+ ]
28+ } ;
You can’t perform that action at this time.
0 commit comments