- 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
原文:https://www.cnblogs.com/taokele/p/12197752.html