vue.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: 'http://192.168.0.248:8082',
  51. },
  52. chainWebpack: config => {
  53. }
  54. }