zoukankan      html  css  js  c++  java
  • webpack升级踩坑

    webpack3.8.1 => webpack4.39.2

    1、error:webpack is not a function

    fix scripts/start.js
    const compiler = createCompiler(webpack, config, appName, urls, useYarn);
    =>
    const compiler = createCompiler({ webpack, config, appName, urls, useYarn });

    2、error: this.htmlWebpackPlugin.getHooks is not a function

    fix config/webpack.config.*.js
    new InterpolateHtmlPlugin(env.raw),
    =>
    new InterpolateHtmlPlugin(HtmlWebpackPlugin,env.raw),

    3、弃用 ExtractTextPlugin =>为 mini-css-extract-plugin

    {
                test: /.(css|less)$/,
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader,
                    },
                    {
                        loader: require.resolve('css-loader'),
                        options: {
                          importLoaders: 1,
                          sourceMap: shouldUseSourceMap,
                        },
                    },
                    {
                        loader: require.resolve('postcss-loader'),
                        options: {
                          // Necessary for external CSS imports to work
                          // https://github.com/facebookincubator/create-react-app/issues/2677
                          ident: 'postcss',
                          plugins: () => [
                            require('postcss-flexbugs-fixes'),
                            autoprefixer({
                              browsers: [
                                '>1%',
                                'last 4 versions',
                                'Firefox ESR',
                                'not ie < 9', // React doesn't support IE8 anyway
                              ],
                              flexbox: 'no-2009',
                            }),
                          ],
                        },
                    },
                    {
                        loader: require.resolve('less-loader'),
                        options: {
                            modifyVars: antdtheme,
                            javascriptEnabled: true
                        },
                    },
                ]
              },
    
    

    4、error: Chunk.initial was removed. Use canBeInitial/isOnlyInitial() at Chunk.get initial

    解决方法:升级 "webpack-manifest-plugin": "^1.3.2" 到 "webpack-manifest-plugin": "^2.0.4"

    5、warning:Tapable.plugin is deprecated. Use new API on .hooks instead

    此警告信息指出某个loader或plugin使用了废弃的api,但不影响打包编译。
    通过获取stracktrace来确定谁发出警告:
    process.traceDeprecation = true;

  • 相关阅读:
    PHP实现栈(Stack)数据结构
    为什么推荐std::string而不是char*
    PHP实现插入排序算法
    OpenCms Application dev-ref
    OpenCMS integration with Spring MVC--reference
    安装opencms时遇到问题及解决方法
    Java ZIP File Example---refernce
    Top 10 Algorithms for Coding Interview--reference
    JVMInternals--reference
    java code to byte code--partone--reference
  • 原文地址:https://www.cnblogs.com/hideonbush/p/11415851.html
Copyright © 2011-2022 走看看