vue.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/hydrologicalManagement': {
  57. //测试环境
  58. target: 'http://192.168.1.185:28131',//http://192.168.1.185:28131
  59. changOrigin: true
  60. },
  61. '/api/announcement': {
  62. //测试环境
  63. target: 'http://192.168.1.185:28131',//http://192.168.1.185:28131
  64. changOrigin: true
  65. },
  66. '/api/monitoringData':{
  67. target: 'http://192.168.1.185:28131',//http://192.168.1.185:28131
  68. changOrigin: true,
  69. },
  70. '/api/ttvideo':{
  71. target:"http://10.157.200.5",
  72. changOrigin:true
  73. },
  74. '/api/ttanalysis':{
  75. target:"http://10.157.200.5",
  76. changOrigin:true
  77. },
  78. '/api/order':{
  79. target:"http://10.157.200.5",
  80. changOrigin:true
  81. }
  82. }
  83. },
  84. css: {
  85. // 启用 CSS modules
  86. // requireModuleExtension: false,
  87. // 是否使用css分离插件
  88. extract: false,
  89. // 开启 CSS source maps,一般不建议开启
  90. sourceMap: false,
  91. // css预设器配置项
  92. loaderOptions: {
  93. sass: {
  94. additionalData: '@import "mars3d-cesium/Build/Cesium/Widgets/widgets.css"; @import "@/assets/scss/index.scss";'
  95. }
  96. }
  97. }
  98. })