vue.config.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. if (process.env.NODE_ENV === 'prod') {
  4. }
  5. const resolve = dir => {
  6. return path.join(__dirname, dir)
  7. }
  8. // 项目部署基础
  9. // 默认情况下,我们假设你的应用将被部署在域的根目录下,
  10. // 例如:https://www.my-app.com/
  11. // 默认:'/'
  12. // 如果您的应用程序部署在子路径中,则需要在这指定子路径
  13. // 例如:https://www.foobar.com/my-app/
  14. // 需要将它改为'/my-app/'
  15. // iview-admin线上演示打包路径: https://file.iviewui.com/admin-dist/
  16. // const BASE_URL = process.env.NODE_ENV === 'production'
  17. const BASE_URL = process.env.NODE_ENV === 'development'
  18. ? '/'
  19. //pad
  20. // : '././'
  21. //web
  22. : '/'
  23. module.exports = {
  24. // Project deployment base
  25. // By default we assume your app will be deployed at the root of a domain,
  26. // e.g. https://www.my-app.com/
  27. // If your app is deployed at a sub-path, you will need to specify that
  28. // sub-path here. For example, if your app is deployed at
  29. // https://www.foobar.com/my-app/
  30. // then change this to '/my-app/'
  31. // baseUrl: BASE_URL,
  32. publicPath: BASE_URL,
  33. // tweak internal webpack configuration.
  34. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  35. // 如果你不需要使用eslint,把lintOnSave设为false即可 es6
  36. lintOnSave: false,
  37. chainWebpack: config => {
  38. config.resolve.alias
  39. .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  40. .set('_c', resolve('src/components'))
  41. },
  42. // 设为false打包时不生成.map文件
  43. productionSourceMap: false,
  44. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  45. devServer: {
  46. // proxy: 'http://127.0.0.1:8888',
  47. // proxy: {
  48. // '/api': {
  49. // target: 'http://127.0.0.1:8888/', //后台服务器的ip地址
  50. // pathRewrite: { '^/api': '/' },
  51. // changeOrigin: true
  52. // }
  53. // }
  54. // proxyTable: {
  55. // '/api': {
  56. // target: 'http://localhost:8888',
  57. // changeOrigin: true,
  58. // pathRewrite: {
  59. // '^/api': ''
  60. // }
  61. // }
  62. // }
  63. },
  64. configureWebpack: config => {
  65. // 为生产环境修改配置...
  66. if (process.env.NODE_ENV === 'production') {
  67. config.mode = 'production'
  68. // 打包文件大小配置
  69. config.performance = {
  70. maxEntrypointSize: 10000000,
  71. maxAssetSize: 30000000
  72. }
  73. }
  74. },
  75. }
  76. //test branches