File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const TEST_HTTP_REQUEST = {
36
36
const TEST_WEBPACK_CONFIG = {
37
37
context : TEST_CONTEXT ,
38
38
output : {
39
+ path : '/test/path' ,
39
40
publicPath : '/test/public/path/' ,
40
41
} ,
41
42
} ;
@@ -76,6 +77,19 @@ async function coreTest(webpackConfig, options) {
76
77
try {
77
78
let render = '' ;
78
79
await renderer ( _ . clone ( TEST_HTTP_REQUEST ) , {
80
+ locals : {
81
+ webpackStats : {
82
+ toJson : ( ) => ( {
83
+ assetsByChunkName : {
84
+ 'test-chunk-a' : 'test-chunk-a-1511941200000.css' ,
85
+ 'test-chunk-b' : [
86
+ 'test-chunk-b-1511941200000.js' ,
87
+ 'test-chunk-b-1511941200000.css' ,
88
+ ] ,
89
+ } ,
90
+ } ) ,
91
+ } ,
92
+ } ,
79
93
send : ( x ) => { render += x ; } ,
80
94
status : ( x ) => { render += `HTTP STATUS: ${ x } \n` ; } ,
81
95
} ) ;
Original file line number Diff line number Diff line change @@ -163,19 +163,21 @@ export default function factory(webpackConfig, options) {
163
163
const { webpackStats } = res . locals ;
164
164
if ( webpackStats ) {
165
165
( { assetsByChunkName } = webpackStats . toJson ( ) ) ;
166
- } else ( { assetsByChunkName } = WEBPACK_STATS ) ;
166
+ } else if ( WEBPACK_STATS ) ( { assetsByChunkName } = WEBPACK_STATS ) ;
167
+ else assetsByChunkName = { } ;
167
168
168
169
const timestamp = moment ( buildInfo . timestamp ) . valueOf ( ) ;
169
170
170
171
if ( context . status ) res . status ( context . status ) ;
171
172
const styles = [ ] ;
172
173
context . chunks . forEach ( ( chunk ) => {
173
174
let assets = assetsByChunkName [ chunk ] ;
175
+ if ( ! assets ) return ;
174
176
if ( ! _ . isArray ( assets ) ) assets = [ assets ] ;
175
177
assets = assets . filter ( asset => asset . endsWith ( '.css' ) ) ;
176
178
assets . forEach ( ( asset ) => {
177
179
styles . push ( (
178
- `<link href ="${ publicPath } ${ asset } " id="tru-style" rel="stylesheet" />`
180
+ `<link data-chunk ="${ chunk } " id="tru-style" href=" ${ publicPath } ${ asset } " rel="stylesheet" />`
179
181
) ) ;
180
182
} ) ;
181
183
} ) ;
You can’t perform that action at this time.
0 commit comments