问题一:

描述:

ValidationError: Invalid options object. Less Loader has been initialized using an options object

原因:

less-loader版本太高,不兼容

解决:

  1. yarna add less-loader@5.0.0 -D

问题二

描述:

解决:

是因为我们是webpack4,所以在运用terser-webpack-plugin的时候一定要注意版本号,要用”terser-webpack-plugin”: “^4.2.3”,版本,否则会报一个 ‘javascript’ 的错误

  1. const TerserPlugin = require('terser-webpack-plugin')
  2. configureWebpack: {
  3. optimization: {
  4. minimizer: [
  5. new TerserPlugin({
  6. terserOptions: {
  7. ecma: undefined,
  8. warnings: false,
  9. parse: {},
  10. compress: {
  11. drop_console: true,
  12. drop_debugger: false,
  13. pure_funcs: ['console.log'], // 移除console
  14. },
  15. },
  16. }),
  17. ],
  18. },
  19. },