vue.config.js 5.9 KB

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