vue.config.js 5.5 KB

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