|
| 1 | +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
| 2 | +const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); |
| 3 | +const path = require("path"); |
| 4 | + |
| 5 | +module.exports = () => { |
| 6 | + return { |
| 7 | + output: { |
| 8 | + path: path.resolve(__dirname, "../dist"), |
| 9 | + publicPath: "/", |
| 10 | + filename: "[name].[contenthash].bundle.js", |
| 11 | + }, |
| 12 | + devtool: false, |
| 13 | + module: { |
| 14 | + rules: [ |
| 15 | + // { |
| 16 | + // test: /\.(css)$/, |
| 17 | + // use: [MiniCssExtractPlugin.loader, "css-loader"], |
| 18 | + // // options: { |
| 19 | + // // sourceMap: false, |
| 20 | + // // }, |
| 21 | + // }, |
| 22 | + { |
| 23 | + test: /\.(scss|css)$/, |
| 24 | + use: [ |
| 25 | + { |
| 26 | + // inject CSS to page |
| 27 | + loader: "style-loader", |
| 28 | + }, |
| 29 | + { |
| 30 | + // translates CSS into CommonJS modules |
| 31 | + loader: "css-loader", |
| 32 | + }, |
| 33 | + { |
| 34 | + // Run postcss actions |
| 35 | + loader: "postcss-loader", |
| 36 | + options: { |
| 37 | + // `postcssOptions` is needed for postcss 8.x; |
| 38 | + // if you use postcss 7.x skip the key |
| 39 | + postcssOptions: { |
| 40 | + // postcss plugins, can be exported to postcss.config.js |
| 41 | + plugins: function () { |
| 42 | + return [require("autoprefixer")]; |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + { |
| 48 | + // compiles Sass to CSS |
| 49 | + loader: "sass-loader", |
| 50 | + options: { |
| 51 | + // Prefer `dart-sass` |
| 52 | + implementation: require("sass"), |
| 53 | + sassOptions: { |
| 54 | + quietDeps: true, |
| 55 | + }, |
| 56 | + }, |
| 57 | + }, |
| 58 | + ], |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + plugins: [ |
| 63 | + new MiniCssExtractPlugin({ |
| 64 | + filename: "styles/[name].[contenthash].css", |
| 65 | + chunkFilename: "[id].css", |
| 66 | + }), |
| 67 | + ], |
| 68 | + optimization: { |
| 69 | + minimize: true, |
| 70 | + minimizer: [new CssMinimizerPlugin(), "..."], |
| 71 | + runtimeChunk: { |
| 72 | + name: "runtime", |
| 73 | + }, |
| 74 | + }, |
| 75 | + performance: { |
| 76 | + hints: false, |
| 77 | + maxEntrypointSize: 512000, |
| 78 | + maxAssetSize: 512000, |
| 79 | + }, |
| 80 | + }; |
| 81 | +}; |
0 commit comments