-
-
Notifications
You must be signed in to change notification settings - Fork 170
Open
Description
- Electron Webpack Version: 2.8.2
- Target: Windows
I've spent a more than a day debugging why my images and sound files were accessible in development but did not appear in the dist folder. Finally I have a "Fix" which is working for me, but I don't understand why is was necessary. Bellow is what I put into my webpack.renderer.js file.
Can anyone explain why the "url-loader" was being used for sound and image files? I'm not experienced in any of this, but because I had this issue is seems to me that this is a bug in electron webpack?
//webpack.renderer.js
var webpack = require('webpack')
fs = require('fs');
function replacer(key, value) {
//RegExp would not print in a useful way without this
if (value instanceof RegExp) {
return value.toString();
}
return value;
}
module.exports = function(config)
{
fs.writeFileSync("webpack.renderer.before.js", JSON.stringify(config, replacer, 4));
// replace image loader rules
config.module.rules[6] = {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: {
loader: 'file-loader',//"url-loader", why was this the default?
options: {
//limit: 10240,
name: "imgs/[name]--[folder].[ext]"
}
},
}
// replace sound loader rules
config.module.rules[7] = {
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
use: {
loader: 'file-loader',//"url-loader", why was this the default?
options: {
//"limit": 10240,
name: "media/[name]--[folder].[ext]"
}
},
}
fs.writeFileSync("webpack.renderer.after.js", JSON.stringify(config, replacer, 4));
return config
}
Metadata
Metadata
Assignees
Labels
No labels