I have created a webpack configuration that uses bootstrap 4 and fontawesome. It has multiple entrypoints and deals with multiple html pages at the same time.
For those who are curiousI have created a repository of my workflow too:
github
It works fine and I am happy with the output. What bothers me is the speed of it. The workflow is super slow which I am unable to figure out. The CPU usage goes 100% as soon as I change some file.
Here is my webpack configuration file:
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: {
home: './src/js/home.js',
login: './src/js/login.js',
signup: './src/js/signup.js',
},
output: {
filename: 'js/[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 9000
},
plugins: [
new HtmlWebpackPlugin({
filename: 'home.html',
template: 'src/home.html',
chunks: ['home'],
inject: false
}),
new HtmlWebpackPlugin({
filename: 'login.html',
template: 'src/login.html',
chunks: ['login'],
inject: false
}),
new HtmlWebpackPlugin({
filename: 'signup.html',
template: 'src/signup.html',
chunks: ['signup'],
inject: false
}),
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "[id].css"
}),
new webpack.HotModuleReplacementPlugin(),
],
module: {
rules: [{
test: /\.(png|jp(e*)g|gif)$/,
use: [{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'images/[hash]-[name].[ext]',
publicPath: '/'
}
}]
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"resolve-url-loader",
"sass-loader"
]
},
]
},
};