vue.config.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. const webpack = require('webpack')
  2. const path = require('path')
  3. const CopyWebpackPlugin = require('copy-webpack-plugin')
  4. const cesiumSource = 'node_modules/cesium/Build/Cesium'
  5. module.exports = {
  6. publicPath: './',
  7. assetsDir: './static',
  8. productionSourceMap: false,
  9. lintOnSave: false, // 是否开启eslint
  10. devServer: {
  11. open: true,
  12. port: 8091,
  13. overlay: {
  14. warnings: false,
  15. errors: true,
  16. },
  17. proxy: {
  18. '/yapi': {
  19. // target: 'http://39.101.177.49:5013/', // 远程服务器-皞哥
  20. // target: 'http://127.0.0.1:18201/prod-api/', // 贵州现场
  21. // target: 'http://11.100.46.218:8080/prod-api/', // 贵都匀现场
  22. // target: 'http://11.100.46.220:8080/prod-api/', // 贵州现场
  23. // target: 'http://192.168.1.10:8080/prod-api/', // 贵州现场
  24. target: 'http://192.168.195.134:8080/prod-api/', // 贵州现场
  25. // target: 'http://172.168.0.62:8080/prod-api/', // 托克托现场
  26. // target: 'http://192.168.195.136:8080/prod-api/', // 托克托本地
  27. // target: 'http://192.168.1.10:8080/prod-api/', // 贵州现场
  28. // target: 'http://11.100.46.220:8080/prod-api/', // 贵州现场
  29. // target: "http://localhost:5002", // 远程服务器-赵哥
  30. // target: "http://127.0.0.1:18914/yapi/",
  31. changeOrigin: true,
  32. pathRewrite: {
  33. '^/yapi': '/',
  34. },
  35. },
  36. '/model': {
  37. // target: 'http://39.101.177.49:5013/model/', //模型服务器
  38. // target: 'http://127.0.0.1:18202/model/', //贵州现场
  39. // target: 'http://11.100.46.220:8081/model/', //都匀现场
  40. // target: 'http://11.100.46.218:8081/model/', //都匀现场
  41. // target: "http://192.168.70.11:8081/model/", // 静海现场
  42. // target: "http://localhost:8000/model/", // 济北综合站现场服务器
  43. // target: 'http://11.100.46.220:8081/model/', //贵阳模型服务器
  44. // target: 'http://192.168.1.10:8081/model/', //贵阳模型服务器
  45. target: 'http://192.168.195.134:8081/model/', //贵阳模型服务器
  46. // target: 'http://172.168.0.62:8081/model/', //托克托模型现场服务器
  47. // target: 'http://192.168.195.136:8081/model/', //托克托模型服务器
  48. changeOrigin: true,
  49. pathRewrite: {
  50. '^/model': '/',
  51. },
  52. },
  53. },
  54. },
  55. configureWebpack: config => {
  56. let plugins = []
  57. if (process.env.NODE_ENV === 'production') {
  58. plugins = [
  59. new webpack.DefinePlugin({
  60. CESIUM_BASE_URL: JSON.stringify('static'),
  61. }),
  62. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Workers'), to: 'static/Workers' }]),
  63. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'static/Assets' }]),
  64. new CopyWebpackPlugin([
  65. {
  66. from: path.join(cesiumSource, 'ThirdParty'),
  67. to: 'static/ThirdParty',
  68. },
  69. ]),
  70. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'static/Widgets' }]),
  71. new webpack.ProvidePlugin({
  72. process: 'process/browser',
  73. Buffer: ['buffer', 'Buffer'],
  74. }),
  75. ]
  76. } else {
  77. plugins = [
  78. new webpack.DefinePlugin({
  79. CESIUM_BASE_URL: JSON.stringify(''),
  80. }),
  81. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Workers'), to: 'Workers' }]),
  82. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
  83. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty'), to: 'ThirdParty' }]),
  84. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
  85. new webpack.ProvidePlugin({
  86. process: 'process/browser',
  87. Buffer: ['buffer', 'Buffer'],
  88. }),
  89. ]
  90. }
  91. return {
  92. module: {
  93. unknownContextCritical: false,
  94. rules: [
  95. {
  96. test: /\.js$/,
  97. enforce: 'pre',
  98. include: path.resolve(__dirname, 'node_modules/cesium/Source'),
  99. sideEffects: false,
  100. use: [
  101. {
  102. loader: 'strip-pragma-loader',
  103. options: {
  104. pragmas: {
  105. debug: false,
  106. },
  107. },
  108. },
  109. ],
  110. },
  111. {
  112. test: /.js$/,
  113. include: path.resolve(__dirname, 'node_modules/cesium/Source'),
  114. use: {
  115. loader: require.resolve('@open-wc/webpack-import-meta-loader'),
  116. },
  117. },
  118. ],
  119. },
  120. optimization: {
  121. usedExports: true,
  122. splitChunks: {
  123. maxInitialRequests: Infinity,
  124. minSize: 0,
  125. maxSize: 250000,
  126. cacheGroups: {
  127. vendor: {
  128. test: /[\\/]node_modules[\\/]/,
  129. priority: -10,
  130. chunks: 'all',
  131. name(module) {
  132. const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
  133. return `npm.${packageName.replace('@', '')}`
  134. },
  135. },
  136. commons: {
  137. name: 'Cesium',
  138. test: /[\\/]node_modules[\\/]cesium/,
  139. priority: 10,
  140. chunks: 'all',
  141. },
  142. },
  143. },
  144. },
  145. output: {
  146. sourcePrefix: ' ',
  147. },
  148. amd: {
  149. toUrlUndefined: true,
  150. },
  151. resolve: {
  152. alias: {
  153. '@': path.resolve('src'),
  154. },
  155. },
  156. node: {
  157. fs: 'empty',
  158. Buffer: false,
  159. http: 'empty',
  160. https: 'empty',
  161. zlib: 'empty',
  162. },
  163. plugins: plugins,
  164. }
  165. },
  166. }