Created
March 13, 2020 09:06
-
-
Save bytrangle/a6bb798b272eb42b9d30327f56acb6c7 to your computer and use it in GitHub Desktop.
This Webpack configuration will output Javascript and CSS files to different directories. Example is dist/js/main.js, dist/css/main.csss, dist/css/bootstrap.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
mode: 'development', | |
entry: path.resolve(__dirname, 'static/index.js'), | |
output: { | |
filename: 'js/[name].js', | |
path: path.resolve(__dirname, 'dist/js'), | |
}, | |
optimization: { | |
runtimeChunk: 'single', | |
splitChunks: { | |
chunks: 'all', | |
maxInitialRequests: Infinity, | |
minSize: 0, | |
cacheGroups: { | |
vendor: { | |
test: /[\\/]node_modules[\\/]/, | |
name(module) { | |
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]; | |
return `${packageName.replace('@', '')}`; | |
}, | |
reuseExistingChunk: true, | |
}, | |
}, | |
}, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.css$/, | |
use: [MiniCssExtractPlugin.loader, 'css-loader'], | |
}, | |
], | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin({ | |
filename: 'css/[name].css', | |
}), | |
new HtmlWebpackPlugin({ | |
title: 'Keywording', | |
template: './static/template.html', | |
}), | |
new BundleAnalyzerPlugin(), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment