51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
const path = require("path");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
module.exports = (env) => {
|
|
return {
|
|
mode: env.production ? "production" : "development",
|
|
entry: "./src/styles.scss",
|
|
devtool: "inline-source-map",
|
|
devServer: {
|
|
contentBase: "./dist",
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
title: "Caching",
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: "[name].css",
|
|
chunkFilename: "[id].css",
|
|
}),
|
|
],
|
|
output: {
|
|
filename: "[name].[contenthash].js",
|
|
path: path.resolve(__dirname, "dist"),
|
|
clean: true,
|
|
publicPath: "/",
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.s[ac]ss/i,
|
|
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
|
|
},
|
|
],
|
|
},
|
|
optimization: {
|
|
moduleIds: "deterministic",
|
|
runtimeChunk: "single",
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
vendor: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name: "vendors",
|
|
chunks: "all",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|