vue.config.js 5.9 KB

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