vue.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // tweak internal webpack configuration.
  26. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  27. // 如果你不需要使用eslint,把lintOnSave设为false即可
  28. lintOnSave: false,
  29. chainWebpack: config => {
  30. config.resolve.alias
  31. // .set('~', resolve('src/assets'))
  32. .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  33. .set('_c', resolve('src/components'))
  34. .set('_p', resolve('src/plugin'))
  35. // config.module
  36. // .rule(/\.js$/)
  37. // .use('babel-loader')
  38. // .loader('babel-loader')
  39. // .exclude(__dirname + 'node_modules')
  40. // .include(__dirname + 'src')
  41. // .tap(options => {
  42. // // 修改它的选项...
  43. // options={presets: ['env']}
  44. // return options
  45. // })
  46. },
  47. // 打包时不生成.map文件
  48. productionSourceMap: false,
  49. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  50. devServer: {
  51. // proxy: 'http://127.0.0.1:10086',
  52. disableHostCheck: true,
  53. proxy:{ //设置代理,必须填
  54. '/api':{ //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
  55. target:'https://qyapi.weixin.qq.com', //代理的目标地址,这是豆瓣接口地址网址
  56. changeOrigin:true, //是否设置同源,输入是的
  57. pathRewrite:{ //路径重写
  58. '/api':'' //路径转发代理 /api 的意思就是 用/api 代替http:localhost:8080
  59. }
  60. },
  61. '':{
  62. target:'http://127.0.0.1:10086',
  63. }
  64. }
  65. }
  66. }