Webpack - does not display a package for a specific entry point

Im uses a file loader to automatically map a bunch of fraud patterns into static html files, but webpack also outputs a pointless file based on the entry point

For example, 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 gets the package file this-shouldnt-emit to the root directory that I don't need.

How can I stop the file loader from releasing the output package, but not stop it from generating all the static html files that it currently has. Is there a plugin or some kind of zero bootloader that I can put at the end of the bootloader chain to kill the bundle emitting?

+6
source share
1 answer

I'm not sure what you are really asking, but if you want it to include multiple files in one package, use an array. The whole point of using [name] in filename: '[name].bundle.js for multiple entries. This is optional (but optional) for a single input key.

This will create two batch files.

 entry: { BUNDLE_KEY_ONE: 'path/file.js', BUNDLE_KEY_TWO: 'path/otherFile.js', } 

Thus, you have several files with one package.

 entry: { SINGLE_BUNDLE_NAME: ['file/one.js', 'file/two.js'] } 
0
source

Source: https://habr.com/ru/post/1015159/


All Articles