vue.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * @Author: WangQiBiao
  3. * @LastEditors: wangjiacheng
  4. * @Description: 配置文件
  5. * @Date: 2019-03-02 14:21:27
  6. * @LastEditTime: 2021-10-15 17:43:29
  7. */
  8. const path = require('path')
  9. const resolve = dir => {
  10. return path.join(__dirname, dir)
  11. }
  12. const BASE_URL = process.env.NODE_ENV === 'production' ? '/screen' : process.env.VUE_APP_SECRET === 'test' ? '/screen' : '/'
  13. const ramdom = parseInt(Math.random() * 10000) // 随机数
  14. module.exports = {
  15. publicPath: BASE_URL,
  16. lintOnSave: true,
  17. configureWebpack: { // 解决发版更新浏览器缓存没有更新的问题
  18. output: {
  19. filename: `[name].[hash].${ramdom}.js`,
  20. chunkFilename: `[name].[hash].${ramdom}.js`
  21. }
  22. },
  23. chainWebpack: config => {
  24. config.resolve.alias
  25. .set('@', resolve('src'))
  26. .set('_c', resolve('src/components'))
  27. .set('_vc', resolve('src/view/components'))
  28. .set('_conf', resolve('config'))
  29. },
  30. // 打包时不生成.map文件
  31. productionSourceMap: false,
  32. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  33. devServer: {
  34. proxy: {
  35. '/api': {
  36. target: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/', // 对应自己的接口
  37. changeOrigin: true,
  38. ws: false,
  39. pathRewrite: {
  40. '^/api': ''
  41. }
  42. }
  43. },
  44. overlay: { // 错误信息显示到浏览器上
  45. warnings: true,
  46. errors: true
  47. }
  48. },
  49. css: {
  50. // 开启样式追溯
  51. sourceMap: true
  52. }
  53. }