webpack3.X 迁移至webpack4.X问题

 

- building for production...(node:22056) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
\ building for production...E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\node_modules\webpack\lib\TemplatedPathPlugin.js:92
                        .replace(
                         ^

TypeError: Cannot read property 'replace' of undefined
    at replacePathVariables (E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\node_modules\webpack\lib\TemplatedPathPlugin.js:92:5)

致使缘由是由于隐藏下边的filename,此行是给css文件添加hash值css

 new ExtractTextPlugin({
      filename: utils.assetsPath('css/[name].[hash].css'),
      allChunks: true,
    }),

 

- building for production...(node:21940) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
| building for production...E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\node_modules\webpack\lib\TemplatedPathPlugin.js:44
                                throw new Error(
                                ^

Error: Path variable [contenthash] not implemented in this context: static/css/[name].[contenthash].css

这是由于extract-text-webpack-plugin插件给css文件添加hash值出错node

解决方法将contenthash改成hash或者去掉webpack

解释了extract-text-webpack-plugin与mini-css-extract-plugin的区别:web

https://blog.csdn.net/lqlqlq007/article/details/83865176app

 

打包后css文件出错post

  
- building for production...(node:11312) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
- building for production...Error processing file: static/css/app.aed755ca29a160df258b.css
Error processing file: static/css/vendor.aed755ca29a160df258b.css
Error processing file: static/css/manifest.aed755ca29a160df258b.css
(node:11312) UnhandledPromiseRejectionWarning: CssSyntaxError: E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\static\css\app.aed755ca29a160df258b.css:2682:47: Missed semicolon
    at Input.error (E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\node_modules\cssnano\node_modules\postcss\lib\input.js:130:16)
    at Parser.checkMissedSemicolon (E:\shjz\projects\Enocare\SRM\srm_web\enocare_srm\node_modules\cssnano\node_modules\postcss\lib\parser.js:603:22)

修改webpack.prod.conf文件,隐藏下边的代码ui

 new OptimizeCSSPlugin({
      cssProcessorOptions: config.build.productionSourceMap
        ? { safe: true, map: { inline: false } }
       : { safe: true }
    }),

https://blog.csdn.net/weixin_42512937/article/details/100105317this

相关文章
相关标签/搜索