如何从1个版本的webpack迁移到4个版本?

时间:2019-04-15 14:10:57

标签: webpack

从1.9迁移到Webpack 4.3版时遇到一些问题 试图根据新标准编辑代码,但是项目无法正常工作。我没有直接从1到4版本找到任何迁移指南。我知道可以找到解决方法,但是我的时间非常有限。感谢您的帮助

这是webpack.config.js代码:

   var path = require("path");
    var webpack = require("webpack");
    const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
      .BundleAnalyzerPlugin;

module.exports = {
  devtool: "cheap-module-eval-source-map",
  entry: [
    'webpack-dev-server/client?http://localhost:5050',
    'webpack/hot/only-dev-server',
    // 'react-hot-loader/patch',
    './index'
  ],
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "dist"),
    publicPath: "/static/"
  },
  resolve: {
    extensions: [".js", ".jsx", ".css"],
    alias: { "react/lib/ReactMount": "react-dom/lib/ReactMount" },

  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
    // new BundleAnalyzerPlugin()
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loaders: ["babel-loader"],
        // loaders: ['react-hot-loader', 'babel-loader'],
        exclude: /node_modules/,
        include: __dirname
      },
      {
        test: /\.css$/,
        loaders: ["style-loader", "css-loader"]
      },
      {
        test: /\.(png|woff|woff2|eot|ttf|svg|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loaders: ["url-loader"]
      }
    ]
  },
  devServer: {
    historyApiFallback: true
  }
};

0 个答案:

没有答案