I have multiple subpages on a site that uses webpack and grunt. Here is my webpack configuration in my Gruntfile.js.
I would like to use webpack to handle all of the subpage JS files.
webpack: {
dev: {
entry: {
test: "./src/js/test.js",
index: "./src/js/index.js",
},
output: {
path: 'dist/js/',
filename: '[name].js',
chunkFilename: '[id].[hash].chunk.js',
publicPath: 'js/'
},
plugins: [
new webpack.SourceMapDevToolPlugin('[file].map', null, '[absolute-resource-path]', '[absolute-resource-path]')
]
},
prod: {
entry: {
test: "./src/js/test.js",
index: "./src/js/index.js",
},
output: {
path: 'dist/js/',
filename: '[name].js',
chunkFilename: '[id].[hash].chunk.js',
publicPath: 'js/'
},
plugins: [
new webpack.optimize.UglifyJsPlugin()
]
}
},
Is there a way to use a wildcard when specifying the entry names? So that any files inside js/ folder is considered an entry point? Also, I'm I configuring webpack correctly? And why is the chunkFileName needed? That seems to create unnecessary javascript. Also, how do I handle the case where there is a common JS for all subpages? There are specific JS files for some subpages, and a common JS file for all subpages.