vue.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const path = require('path')
  2. const resolve = dir => {
  3. return path.join(__dirname, dir)
  4. }
  5. // 项目部署基础
  6. // 默认情况下,我们假设你的应用将被部署在域的根目录下,
  7. // 例如:https://www.my-app.com/
  8. // 默认:'/'
  9. // 如果您的应用程序部署在子路径中,则需要在这指定子路径
  10. // 例如:https://www.foobar.com/my-app/
  11. // 需要将它改为'/my-app/'
  12. // iview-admin线上演示打包路径: https://file.iviewui.com/admin-dist/
  13. const BASE_URL = process.env.NODE_ENV === 'production'
  14. ? '/'
  15. : '/'
  16. module.exports = {
  17. // Project deployment base
  18. // By default we assume your app will be deployed at the root of a domain,
  19. // e.g. https://www.my-app.com/
  20. // If your app is deployed at a sub-path, you will need to specify that
  21. // sub-path here. For example, if your app is deployed at
  22. // https://www.foobar.com/my-app/
  23. // then change this to '/my-app/'
  24. // baseUrl: BASE_URL,
  25. publicPath: BASE_URL,
  26. // tweak internal webpack configuration.
  27. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  28. // 如果你不需要使用eslint,把lintOnSave设为false即可
  29. lintOnSave: true,
  30. chainWebpack: config => {
  31. config.resolve.alias
  32. .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  33. .set('_c', resolve('src/components'))
  34. },
  35. // 设为false打包时不生成.map文件
  36. productionSourceMap: false,
  37. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  38. // devServer: {
  39. // proxy: 'localhost:3000'
  40. // }
  41. /* devServer: {
  42. port: 8081,
  43. proxy: 'https://app.tjzhxx.cn:10443/index.php'
  44. } */
  45. devServer: {
  46. proxy: {
  47. '/urllab': {
  48. target: 'https://app.tjzhxx.cn:1443/',
  49. // 路径重写
  50. pathRewrite: { '^/urllab': '' },
  51. changeOrigin: true
  52. }
  53. }
  54. }
  55. }