vue.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * @Author: WangQiBiao
  3. * @LastEditors: wjc
  4. * @Description: 配置文件
  5. * @Date: 2019-03-02 14:21:27
  6. * @LastEditTime: 2024-05-11 11:00:00
  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: false,
  46. errors: false
  47. }
  48. },
  49. css: {
  50. // 开启样式追溯
  51. sourceMap: true,
  52. loaderOptions: {
  53. scss: {
  54. prependData: `@import "@/assets/css/mixin.scss";`
  55. }
  56. }
  57. }
  58. }