首页 > Web开发 > 详细

webpack3.X 迁移至webpack4.X问题

时间:2020-01-15 18:10:22      阅读:158      评论:0      收藏:0      [点我收藏+]

 

- 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值

 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值出错

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

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

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

 

打包后css文件出错

  
- 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文件,隐藏下边的代码

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

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

webpack3.X 迁移至webpack4.X问题

原文:https://www.cnblogs.com/taokele/p/12197752.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!