vue.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. },
  29. configureWebpack: {
  30. resolve: {
  31. alias: {
  32. '@': resolve('src'),
  33. 'view': resolve('src/view'),
  34. 'assets': resolve('src/assets'),
  35. 'common': resolve('src/common')
  36. }
  37. },
  38. externals: {
  39. Vue: 'vue',
  40. 'router': 'router',
  41. 'ElementUI': 'element-ui'
  42. }
  43. },
  44. devServer: {
  45. host: '0.0.0.0',
  46. port: 8080,
  47. https: false,
  48. hotOnly: false,
  49. proxy: null, // 设置代理
  50. before: app => {
  51. }
  52. }
  53. };