Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  100] [ 5]  / answers: 1 / hits: 6007  / 6 Years ago, tue, november 27, 2018, 12:00:00

In my application I have multiple entry points.
One entry point is creating a bundle which is restricted only for signed in users.



Is there a way to tell webpack to not bundle any file that needs to be restricted into the 'public' bundle? and instead not bundle it / throw a compilation error?



is there an exclude per entry point?



The only solution I can think of is creating two separate webpack config files, is there a better way?



Thanks



--- edit ---



I will try to rephrase the question -
Is there a way to enforce that some files will be excluded from a specific bundle/entry point, or in other words, there are files that I want in a specific bundle, and not in a any other bundle, and I want to enforce it.


More From » webpack

 Answers
1

From the Webpack documentation link :
Exclude File and Multiple Configurations



module.exports = [{
output: {
filename: './dist-amd.js',
libraryTarget: 'amd'
},
name: 'amd',
entry: './app.js',
mode: 'production',
rules: [
{
test: /.js$/,
exclude: [
'src/configs/configs/your1.js'
]
}
]
}, {
output: {
filename: './dist-commonjs.js',
libraryTarget: 'commonjs'
},
name: 'commonjs',
entry: './app2.js',
mode: 'production',
rules: [
{
test: /.js$/,
exclude: [
'src/configs/configs/your2.js'
]
}
]
}];

};


Special thanks to @Axnyff for completing my answer.


[#10125] Saturday, November 24, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrances

Total Points: 184
Total Questions: 100
Total Answers: 92

Location: Tokelau
Member since Sun, May 7, 2023
1 Year ago
;