webpack config postcss hot build不起作用

时间:2019-07-02 05:10:03

标签: node.js webpack postcss

CLI窗口对我说:

  

您没有设置任何插件,解析器或字符串化器。现在,PostCSS不执行任何操作。在https://www.postcss.parts/上为您的案例选择插件,并在postcss.config.js

中使用它们

所以,我可以热建项目。

const buildConfig = merge(baseConfig, {
  output: {
    hotUpdateChunkFilename: "hot/hot-update.js",
    hotUpdateMainFilename: "hot/hot-update.json"
  },
  optimization: {
    minimize: false
  },
  devtool: "inline-source-map",
  module: {
    rules: [
      {
        test: /\.ts(x?)$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "babel-loader",
            options: {
              babelrc: false,
              sourceMap: true,
              cacheDirectory: true,
              plugins: ["react-hot-loader/babel"],
              presets: ["@babel/preset-env"]
            }
          },
          {
            loader: "ts-loader",
            options: { logLevel: "info", silent: false, logInfoToStdOut: true }
          }
        ]
      },
      {
        test: /\.[s]*css$/,
        use: [
          {
            loader: "css-loader",
            options: {
              publicPath: ".",
              importLoaders: 1,
              url: false,
              minimize: true
            }
          },
          {
            loader: "postcss-loader",
            options: {
              publicPath: ".",
              config: {
                path: path.join(__dirname, "./postcss.config.js")
              }
            }
          }
        ]
      }
    ]
  },
  devServer: {
    host: "localhost",
    port: port,
    contentBase: path.join(__dirname, DEFINES.paths.wwwroot),
    disableHostCheck: true, // host 0.0.0.0 일 경우 보안상 문제로 추가
    compress: false,
    noInfo: true,
    stats: "errors-only",
    inline: true,
    lazy: false,
    hot: true,
    https: https,
    headers: {
      "Access-Control-Allow-Origin": "*"
    },
    watchOptions: {
      aggregateTimeout: 300,
      poll: 100
    },
    historyApiFallback: {
      verbose: true,
      disableDotRule: false
    }
  },
  plugins: [new webpack.HotModuleReplacementPlugin()]
});

module.exports = buildConfig;

0 个答案:

没有答案