vue.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: zhuyijun
  5. * @Date: 2022-02-17 14:34:36
  6. * @LastEditTime: 2022-02-20 16:43:39
  7. */
  8. module.exports = {
  9. chainWebpack: config => {
  10. //发布模式
  11. config.when(process.env.NODE_ENV === 'production', config => {
  12. config.entry('app').clear().add('./src/main-prod.js')
  13. //通过 externals 加载外部cdn资源
  14. config.set('externals', {
  15. vue: 'Vue',
  16. 'vue-router': 'VueRouter',
  17. axios: 'axios',
  18. lodash: '_',
  19. echarts: 'echarts',
  20. nprogress: 'NProgress',
  21. 'vue-quill-editor': 'VueQuillEditor'
  22. })
  23. config.plugin('html').tap(args => {
  24. args[0].isProd = true
  25. return args
  26. })
  27. })
  28. //开发模式
  29. config.when(process.env.NODE_ENV === 'development', config => {
  30. config.entry('app').clear().add('./src/main-dev.js')
  31. //通过 externals 加载外部cdn资源
  32. config.set('externals', {
  33. vue: 'Vue',
  34. 'vue-router': 'VueRouter',
  35. axios: 'axios',
  36. lodash: '_',
  37. echarts: 'echarts',
  38. nprogress: 'NProgress',
  39. 'vue-quill-editor': 'VueQuillEditor'
  40. })
  41. config.plugin('html').tap(args => {
  42. args[0].isProd = false
  43. return args
  44. })
  45. })
  46. },
  47. lintOnSave: false
  48. }