vue.config.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const { defineConfig } = require('@vue/cli-service')
  2. const port = process.env.port || process.env.npm_config_port || 80; // 端口
  3. module.exports = defineConfig({
  4. // 部署生产环境和开发环境下的URL。
  5. // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上。
  6. // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
  7. publicPath: process.env.NODE_ENV === "production" ? "/gcdist/" : "/",
  8. // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
  9. outputDir: "dist",
  10. // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
  11. assetsDir: "static",
  12. // 是否开启eslint保存检测,有效值:ture | false | 'error'
  13. lintOnSave: process.env.NODE_ENV === "development",
  14. // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
  15. productionSourceMap: false,
  16. transpileDependencies: true,
  17. devServer: {
  18. host: "0.0.0.0",
  19. port: port,
  20. client: {
  21. overlay: false,
  22. },
  23. proxy: {
  24. '/pdcApi': {
  25. // target: 'https://app.slt.fujian.gov.cn:', // 你的后端服务器地址
  26. changeOrigin: true,
  27. target: 'http://39.98.38.2:18089/dc-api/',
  28. // target: "http://127.0.0.1:8500/",
  29. pathRewrite: {
  30. '^/pdcApi': '' // 移除路径中的/api18185前缀
  31. }
  32. }
  33. }
  34. },
  35. css: {
  36. loaderOptions: {
  37. sass: {
  38. // additionalData: `@import "@/assets/styles/index.scss";`, // 不同版本的 sass,此属性不同:data、prependData、additionalData
  39. sassOptions: { outputStyle: 'expanded' } // fix: 解决 element-ui 图标 icon 偶现乱码问题
  40. }
  41. }
  42. },
  43. chainWebpack: config => {
  44. config.plugin('define').tap(definitions => {
  45. Object.assign(definitions[0], {
  46. __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
  47. });
  48. return definitions;
  49. });
  50. }
  51. })