I use a webpack config in which I use an array of file paths as entry point. Also known as multi-main entry. These files are not dependant on each other, but I want to bundle them. The js bundle just fine. Webpack creates a bundle js file containing the contents of all js files.
But I also want to bundle my css files. They are also not dependant on each other so no import rule is used in the css code. Only the multi-main webpack entry. For this I use the file-loader. But I end up with separate files or the last overwrites the first.
A simplification of my code
webpack({
entry: [
'./jsFileA.js',
'./jsFileB.js',
'./cssFileA.css',
'./cssFileB.css'
],
output: {
path: './',
filename: 'bundle.js'
},
module: {
rules: [{
test: /\.css$/,
use: [{
loader: css-loader
}, {
loader: style-loader
}, {
loader: 'file-loader',
options: {
name: 'bundle.css'
}
}]
}]
}
}, (error, stats) => {
console.log(stats);
})
This will end up with a bundle.css containing only the css of the last css file. The first get's overwritten by the second. If I use a [hash] in the file name like name: '[hash].css'
I end up with two css files.
So it looks like the file-loader doesn't bundle multi main entry points. Is this how file-loader works? Or is it possible to use file-loader and bundle multi main entry points?