今天再重新配置老專案node打包環境的時候遇到了一個問題,
在打包的時候報:
TypeError: Cannot read property 'compilation' of undefined 錯誤,
(這里需要強調一下,安裝環境的使用一定要-save-dev或者是-save,否則欲哭無淚啊)
很明顯,這是node一些包的版本對應不上的問題,,,
1、首先定位到uglifyjs-webpack-plugin中的index.js檔案中,將專案中的該包升級或者降級到1.0.0版本
npm i [email protected] --save
2、然后定位到optimize-css-assets-webpack-plugin\node_modules\last-call-webpack-plugin\src\index.js檔案報錯
將專案中的該包(optimize-css-assets-webpack-plugin)升級或者降級到2.0.0版本
npm i optimize-css-assets-webpack-plugin@2 --save
3、這個時候報缺少"cssnano"包,直接安裝上即可(到這一步就成功了)
4、最后附上丑化壓縮配置
// CSS壓縮丑化
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
// JavaScript壓縮丑化
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
}
},
sourceMap: true,
parallel: true
}),
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true,
map: {
inline: false
}
}
}),
站在巨人的肩膀上摘蘋果:
原文:https://blog.csdn.net/u011169370/article/details/83346176
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/31024.html
標籤:其他
上一篇:VUE路徑問題
下一篇:(vue操作storage)Vue plugin for work with local storage,session storage and memo
