Im using a file-loader to automatically render a bunch of pug templates to static html files, but webpack is also outputting a pointless file based on the entry point
Eg this is in my webpack.config.js:
entry: {
'js/build/bundle.js': './js/app.js',
'this-shouldnt-emit': './pug/.pug.js' //pug entry point
},
output: {
path: path.join(__dirname, '../'),
filename: '[name]'
},
...
// pug loading module rule
{
test: /\.pug$/,
include: path.resolve(__dirname, "../pug"),
use: [
"file-loader?name=[path][name].html&context=./pug",
"pug-html-loader?pretty&exports=false"
]
}
and Im getting a this-shouldnt-emit
bundle file in the root build directory, which I dont want.
How can I stop the file-loader from emitting an output bundle, but not interfere with it generating all the static html files it currently is. Is there a plugin or some kind of null loader I can put at the end of the loader chain to kill the bundle emitting?
webpack.config.jsmodule. exports = { entry: { main: './path/to/my/entry/file. js', }, }; We can also pass an array of file paths to the entry property which creates what is known as a "multi-main entry".
Webpack v4+ will minify your code by default in production mode .
Actually, those 'include' and 'exclude' properties are telling the loaders whether to include/exclude the files described (such as the contents of node_modules ), not webpack itself.
Chunk: This webpack-specific term is used internally to manage the bundling process. Bundles are composed out of chunks, of which there are several types (e.g. entry and child).
I am not sure of what you are really asking but if you want it include multiple files in one bundle, use an array. The whole point of using [name]
in filename: '[name].bundle.js
is for multiple entries. It is not necessary (but optional) for one entry key.
This will create two bundle files.
entry: {
BUNDLE_KEY_ONE: 'path/file.js',
BUNDLE_KEY_TWO: 'path/otherFile.js',
}
This is how you have multiple files one bundle.
entry: {
SINGLE_BUNDLE_NAME: ['file/one.js', 'file/two.js']
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With