vue.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const path = require('path');
  2. function resolve(dir) {
  3. return path.join(__dirname, dir);
  4. }
  5. const cdn = {
  6. js: [
  7. // vue 必须优先加载(生产环境使用最小运行时版本runtime.min, 其他环境使用全版本)
  8. process.env.NODE_ENV !== 'production'
  9. ? 'https://cdn.bootcss.com/vue/2.6.10/vue.js' : 'https://cdn.bootcss.com/vue/2.6.9/vue.runtime.min.js',
  10. // vue-router
  11. 'https://cdn.bootcss.com/vue-router/3.0.6/vue-router.min.js',
  12. // element js
  13. 'https://unpkg.com/element-ui/lib/index.js'
  14. ],
  15. css: [
  16. // element css
  17. 'https://unpkg.com/element-ui/lib/theme-chalk/index.css'
  18. ]
  19. };
  20. module.exports = {
  21. lintOnSave: false,
  22. chainWebpack: (config) => {
  23. // 通过 html-webpack-plugin注入到 index.html
  24. config.plugin('html').tap(args => {
  25. args[0].cdn = cdn;
  26. return args;
  27. });
  28. config.plugins.delete('optimize-css')
  29. },
  30. configureWebpack: {
  31. resolve: {
  32. alias: {
  33. '@': resolve('src'),
  34. 'view': resolve('src/view'),
  35. 'assets': resolve('src/assets'),
  36. 'common': resolve('src/common')
  37. }
  38. },
  39. externals: {
  40. Vue: 'vue',
  41. 'router': 'router',
  42. 'ElementUI': 'element-ui'
  43. }
  44. },
  45. devServer: {
  46. host: '0.0.0.0',
  47. port: 8080,
  48. https: false,
  49. hotOnly: false,
  50. proxy: null, // 设置代理
  51. before: app => {
  52. }
  53. }
  54. };