vue.config.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const { defineConfig } = require('@vue/cli-service')
  2. const path = require('path')
  3. const webpack = require('webpack')
  4. const CopyWebpackPlugin = require('copy-webpack-plugin')
  5. const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
  6. module.exports = defineConfig({
  7. transpileDependencies: true,
  8. publicPath: '/',
  9. assetsDir: 'static',
  10. outputDir: 'dist',
  11. lintOnSave: false, // 是否开启eslint
  12. productionSourceMap: false, // 生产环境是否生成sourceMap
  13. filenameHashing: true, // 文件名哈希
  14. configureWebpack: (config) => {
  15. if (process.env.VUE_APP_MARS3D_SOURCE === 'module') {
  16. const cesiumSourcePath = 'node_modules/mars3d-cesium/Build/Cesium/' // cesium库安装目录
  17. const cesiumRunPath = './mars3d-cesium/' // cesium运行时路径
  18. let plugins = [
  19. // 标识cesium资源所在的主目录,cesium内部资源加载、多线程等处理时需要用到
  20. new webpack.DefinePlugin({
  21. CESIUM_BASE_URL: JSON.stringify(path.join(config.output.publicPath, cesiumRunPath))
  22. }),
  23. // Cesium相关资源目录需要拷贝到系统目录下面(部分CopyWebpackPlugin版本的语法可能没有patterns)
  24. new CopyWebpackPlugin({
  25. patterns: [
  26. { from: path.join(cesiumSourcePath, 'Workers'), to: path.join(config.output.path, cesiumRunPath, 'Workers') },
  27. { from: path.join(cesiumSourcePath, 'Assets'), to: path.join(config.output.path, cesiumRunPath, 'Assets') },
  28. { from: path.join(cesiumSourcePath, 'ThirdParty'), to: path.join(config.output.path, cesiumRunPath, 'ThirdParty') },
  29. { from: path.join(cesiumSourcePath, 'Widgets'), to: path.join(config.output.path, cesiumRunPath, 'Widgets') }
  30. ]
  31. }),
  32. new NodePolyfillPlugin()
  33. ]
  34. return {
  35. module: { unknownContextCritical: false }, // 配置加载的模块类型,cesium时必须配置
  36. plugins: plugins
  37. }
  38. } else {
  39. return {
  40. externals: { 'mars3d-cesium': 'Cesium' } //排除使用 mars3d-cesium
  41. }
  42. }
  43. },
  44. devServer: {
  45. client: { overlay: false },
  46. host: '0.0.0.0', // 也可以直接写IP地址这样方便真机测试
  47. port: 3000, // 端口号
  48. open: false, // 配置自动启动浏览器
  49. proxy: {
  50. '/system-biz': {
  51. target: 'http://10.157.225.55:28085',
  52. logLevel: 'debug',
  53. changeOrigin: true,
  54. rewrite: (p) => p.replace(/^\/system-biz/, '')
  55. },
  56. '/api/announcement': {
  57. //测试环境
  58. target: 'http://10.157.225.55:28083',//http://192.168.1.185:28131
  59. changOrigin: true,
  60. pathRewrite: {
  61. '^/api/announcement': '/api/announcement'
  62. }
  63. },
  64. '/api/hydrologicalManagement': {
  65. //测试环境
  66. target: 'http://10.157.225.55:28083',//http://192.168.1.185:28131
  67. changOrigin: true,
  68. pathRewrite: {
  69. '^/api/hydrologicalManagement': '/api/hydrologicalManagement'
  70. }
  71. },
  72. '/api/monitoringData':{
  73. target: 'http://10.157.225.55:28083',//http://192.168.1.185:28131
  74. changOrigin: true,
  75. pathRewrite: {
  76. '^/api/monitoringData': '/api/monitoringData'
  77. }
  78. },
  79. '/api/ttvideo':{
  80. target:"http://10.157.200.5",
  81. changOrigin:true,
  82. pathRewrite: {
  83. '^/api/ttvideo': '/api/ttvideo'
  84. }
  85. },
  86. '/api/ttanalysis':{
  87. target:"http://10.157.200.5",
  88. changOrigin:true,
  89. pathRewrite: {
  90. '^/api/ttanalysis': '/api/ttanalysis'
  91. }
  92. },
  93. '/api/order':{
  94. target:"http://10.157.200.5",
  95. changOrigin:true,
  96. pathRewrite: {
  97. '^/api/order': '/api/order'
  98. }
  99. }
  100. }
  101. },
  102. css: {
  103. // 启用 CSS modules
  104. // requireModuleExtension: false,
  105. // 是否使用css分离插件
  106. extract: false,
  107. // 开启 CSS source maps,一般不建议开启
  108. sourceMap: false,
  109. // css预设器配置项
  110. loaderOptions: {
  111. sass: {
  112. additionalData: '@import "mars3d-cesium/Build/Cesium/Widgets/widgets.css"; @import "@/assets/scss/index.scss";'
  113. }
  114. }
  115. }
  116. })