Closed mrdulin closed 6 years ago
I just struggled through this, so it should definitely be better documented, but the way to do this, is to set the name
parameter AND set output.chunkFilename
.
for exmample:
module.exports = {
entry: { ... },
output : {
path : ...,
filename : '[name].js',
chunkFilename : '[id].[name].js', // or whatever other format you want.
},
}
then require the resources like so require('bundle-loader?name=[name]./some-module.js');
@MobiusHorizons Mind sending a PR ? 😛
I was already thinking of doing that when i'm done here at work.
@MobiusHorizons Bundle-loader
seems don't support dynamic name
parameter.
This is not working.
const loadModule = moduleName => {
const defaultFile = 'index.js';
return new Promise((resolve, reject) => {
const bundle = require(`bundle-loader?name=${moduleName}!./containers/${moduleName}/${defaultFile}`);
bundle(function (module) {
const Component = module.default;
resolve(Component);
});
});
};
This is working.
const bundle = require(`bundle-loader?name=about!./containers/about/index.js`);
bundle(function (module) {
const Component = module.default;
console.log(Component);
});
here is my code:
webpack
output:But the chunk filename is
1.1.js
,2.2.js
,3.3.js
. I want to get the module filename like:[id].[name].js
.But when I modify my code like this:
webpack
output:bundle-loader
not work. It does not generate my module chunks.