Last active
April 9, 2023 10:57
-
-
Save mavericksbalitaan/e46fdb39559f894c181369619d8e117a to your computer and use it in GitHub Desktop.
Webpack Boilerplate
This file contains 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
const path = require('path'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); | |
module.exports = { | |
mode: 'development', | |
entry: './src/index.js', | |
devtool: 'inline-source-map', | |
devServer: { | |
static: './dist', | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: './src/index.html', | |
}), | |
new FaviconsWebpackPlugin('./src/assets/favicon.png'), | |
new MiniCssExtractPlugin({ | |
filename: 'style.css', | |
}), | |
], | |
output: { | |
filename: 'index.js', | |
path: path.resolve(__dirname, 'dist'), | |
clean: true, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.s[ac]ss$/i, | |
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'], | |
}, | |
{ | |
test: /\.(png|svg|jpg|jpeg|gif)$/i, | |
type: 'asset/resource', | |
}, | |
{ | |
test: /\.(woff|woff2|eot|ttf|otf)$/i, | |
type: 'asset/resource', | |
}, | |
{ | |
test: /\.html$/i, | |
loader: "html-loader", | |
}, | |
], | |
}, | |
optimization: { | |
minimizer: [ | |
new CssMinimizerPlugin(), | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment