vue.config.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const CopyWebpackPlugin = require('copy-webpack-plugin')
  4. const CompressionPlugin = require("compression-webpack-plugin")
  5. let cesiumSource = './node_modules/cesium/Source'
  6. let cesiumWorkers = '../Build/Cesium/Workers'
  7. const plugins = []
  8. module.exports = {
  9. assetsDir: process.env.VUE_APP_STATIC_URL,
  10. publicPath: process.env.NODE_ENV === 'production' ? '' : '',
  11. productionSourceMap: false,
  12. configureWebpack: config => {
  13. if (process.env.NODE_ENV === 'production') {
  14. plugins.push(new CompressionPlugin({
  15. test: /\.js$|\.html$|.\css/, //匹配文件名
  16. threshold: 10240, //对超过10k的数据压缩
  17. deleteOriginalAssets: false //不删除源文件
  18. }))
  19. }
  20. return {
  21. amd: {
  22. toUrlUndefined: true
  23. },
  24. output: {
  25. sourcePrefix: ' '
  26. },
  27. resolve: {
  28. alias: {
  29. 'vue$': 'vue/dist/vue.esm.js',
  30. '@': path.resolve('src'),
  31. 'cesium': path.resolve(__dirname, cesiumSource)
  32. }
  33. },
  34. plugins: [
  35. new CopyWebpackPlugin([{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' }]),
  36. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
  37. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
  38. new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
  39. new webpack.DefinePlugin({
  40. CESIUM_BASE_URL: JSON.stringify('./')
  41. })
  42. ].concat(plugins),
  43. module: {
  44. unknownContextCritical: /^.\/.*$/,
  45. unknownContextCritical: false // 6
  46. }
  47. }
  48. },
  49. devServer: {
  50. proxy: {
  51. '/data': {
  52. target: 'http://map.4dage.com/'
  53. },
  54. '/': {
  55. target: 'http://map.4dage.com/'
  56. }
  57. }
  58. },
  59. chainWebpack: config => {
  60. }
  61. }