内置的Mini-css-extract-plugin hmr支持即使在最简单的示例上也无法正常工作

时间:2019-05-06 21:49:09

标签: webpack webpack-4 webpack-hmr mini-css-extract-plugin webpack-cli

我从mini-css-extract-plugin的GitHub获得了基本配置,并且Hot Module Replacement无法正常工作。即使使用基本的HTML,CSS和JS。

我正在使用

"css-loader": "^2.1.1",
"mini-css-extract-plugin": "^0.6.0",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.2"

我的脚本正在更改Webpack的模式

  "scripts": {
    "serve": "webpack --mode development --watch",
    "dist": "webpack --mode production"
  },

这是我的Webpack配置文件

const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
  plugins: [
    new MiniCssExtractPlugin({
      filename: "[name].css",
    }),
  ],
  entry: ["./style.css", "./app.js"],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              publicPath: "../",
              hmr: process.env.NODE_ENV === "development",
              reloadAll: true,
            },
          },
          "css-loader",
        ],
      },
    ],
  },
};

这是仓库https://github.com/filipw01/mini-css-with-hmr的链接

0 个答案:

没有答案