Load and output sass

This commit is contained in:
2021-04-29 21:00:52 -05:00
parent dcf99e5409
commit 788eb99dcd
8 changed files with 398 additions and 70 deletions

View File

@@ -1,35 +1,50 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: 'development',
entry: './src/index.js',
devtool: 'inline-source-map',
devServer: {
contentBase: './dist',
},
plugins: [
new HtmlWebpackPlugin({
title: 'Caching',
})
],
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
publicPath: '/',
},
optimization: {
moduleIds: 'deterministic',
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
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",
},
},
},
},
},
};
};