vue.config.js 2.1 KB

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