ncu版本管理器 升级element ui 到最新版本需要的方法

895 阅读1分钟
  • 安装ncu版本管理器

    npm install npm-check-updates 使用ncu命令查看可以升级的插件 ncu -u 插件名进行定义升级

  • 注意:ncu -u element-ui 之后一定要使用 npm install 更新插件

  • ncu -u出现问题

  1. ncu : 无法加载文件 D:\nodejs\ncu.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go. microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
    需要以管理员方式打开powershell
    运行命令:set-ExecutionPolicy RemoteSigned
  • 升级成功之后修改utils.js这个配置文件
    if (options.extract) {
      loaders.push(MiniCssExtractPlugin.loader)
    } else {
      loaders.push('vue-style-loader')
    }
    
    修改为
    if (options.extract) {
      loaders.push({
        loader: MiniCssExtractPlugin.loader,
        options: { publicPath: '../../' }
      })
    } else {
      loaders.push('vue-style-loader')
    }
    
  • 打包删除console.log

    找到webpack.prod.conf.js这个配置文件 找到以下代码

    optimization: {
        minimizer: [
          new UglifyJsPlugin({
            uglifyOptions: {
              mangle: {
                safari10: true
              }
            },
            sourceMap: config.build.productionSourceMap,
            cache: true,
            parallel: true
          }),
          // Compress extracted CSS. We are using this plugin so that possible
          // duplicated CSS from different components can be deduped.
          new OptimizeCSSAssetsPlugin()
    ]
    }
    
    修改为
    optimization: {
      minimizer: [
        new UglifyJsPlugin({
          uglifyOptions: {
            mangle: {
              safari10: true
            },
            compress: { // webpack打包时删除console.log
              warnings: false,
              drop_debugger: true,
              drop_console: true
            }
          },
          sourceMap: config.build.productionSourceMap,
          cache: true,
          parallel: true
        }),
        // Compress extracted CSS. We are using this plugin so that possible
        // duplicated CSS from different components can be deduped.
        new OptimizeCSSAssetsPlugin()
      ]
    }