/*
 * @Author: WangQiBiao
 * @LastEditors: wjc
 * @Description: 配置文件
 * @Date: 2019-03-02 14:21:27
 * @LastEditTime: 2025-12-01 10:00:14
 */
const path = require('path')

const resolve = dir => {
  return path.join(__dirname, dir)
}
const BASE_URL = process.env.NODE_ENV === 'production' ? '/screen' : process.env.VUE_APP_SECRET === 'test' ? '/screen' : '/'
const ramdom = parseInt(Math.random() * 10000) // 随机数

module.exports = {
  publicPath: BASE_URL,
  lintOnSave: true,
  configureWebpack: { // 解决发版更新浏览器缓存没有更新的问题
    output: {
      filename: `[name].[hash].${ramdom}.js`,
      chunkFilename: `[name].[hash].${ramdom}.js`
    }
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'))
      .set('_vc', resolve('src/view/components'))
      .set('_conf', resolve('config'))
  },
  // 打包时不生成.map文件
  productionSourceMap: false,
  // 这里写你调用接口的基础路径，来解决跨域，如果设置了代理，那你本地开发环境的axios的baseUrl要写为 '' ，即空字符串
  devServer: {
    proxy: {
      '/api': {
        target: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/', // 对应自己的接口
        changeOrigin: true,
        ws: false,
        pathRewrite: {
          '^/api': ''
        }
      }
    },
    overlay: { // 错误信息显示到浏览器上
      warnings: false,
      errors: false
    }
  },
  css: {
    // 开启样式追溯
    sourceMap: true,
    loaderOptions: {
      scss: {
        prependData: `@import "@/assets/css/mixin.scss";`
      }
    }
  }
}
