-
Notifications
You must be signed in to change notification settings - Fork 17
Description
After upgrading node, I'm having the following issue. The webpack.config.js file generated by the console command webpack/generate-webpack triggers an error. The error has to do with assets-webpack-plugin.
In my case assets plugin generates something like this:
{ manifest: { js: 'manifest.js' },
charts: { js: 'charts.js', css: '../css/charts.css' },
main: { js: 'main.js', css: '../css/main.css' },
admin: { js: 'admin.js', css: '../css/admin.css' },
'':
{ eot:
[ '../fonts/example/example.eot',
'../_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot' ],
ttf:
[ '../fonts/example/example.ttf',
'../_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.ttf' ],
woff:
[ '../fonts/example/example.woff',
'../_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff' ],
svg:
[ '../_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.svg',
'../fonts/example/example.svg' ],
woff2: '../_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff2',
gz:
[ 'admin.js.gz',
'manifest.js.gz',
'../css/charts.css.gz',
'../css/admin.css.gz',
'../css/main.css.gz',
'charts.js.gz',
'main.js.gz' ] } }
Whether using the empty string as the array key is a valid practice is up to debate (it is briefly mentioned in an issue for the plugin itself), this kind of data triggers an error in the following code:
processOutput: function (assets) {
var i;
var j;
for (i in assets) {
if(assets.hasOwnProperty(i)) {
for (j in assets[i]) {
if (assets[i].hasOwnProperty(j)) {
assets[i][j] = path.join(config.assets.scripts, assets[i][j]).replace('\\', '/');
}
}
}
}
return JSON.stringify(assets, null, this.prettyPrint ? 2 : null);
}
When assets[i][j] is an array, not a string, path.join fails with an error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string.
As a temporary solution, I've added a check (if (!Array.isArray(assets[i][j])) { ...) which does solve the problem for now. What's the proper way of solving this?