vue.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path');
  2. const common = path.resolve(__dirname, '../common');
  3. const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
  4. const CompressionPlugin = require('compression-webpack-plugin');
  5. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  6. const productionGzipExtensions = /\.(js|css|json|txt|svg|png)(\?.*)?$/i;
  7. module.exports = {
  8. publicPath: `/${process.env.VUE_APP_ROUTER}`,
  9. outputDir: process.env.VUE_APP_ROUTER,
  10. productionSourceMap: false,
  11. configureWebpack: (config) => {
  12. Object.assign(config, {
  13. resolve: {
  14. alias: {
  15. '@': path.resolve(__dirname, './src'),
  16. '@c': path.resolve(__dirname, './src/components'),
  17. '@a': path.resolve(__dirname, './src/assets'),
  18. '@common': common,
  19. },
  20. },
  21. });
  22. if (process.env.NODE_ENV === 'production') {
  23. return {
  24. plugins: [
  25. new CompressionPlugin({
  26. test: productionGzipExtensions,
  27. threshold: 10240,
  28. deleteOriginalAssets: false,
  29. }),
  30. new BundleAnalyzerPlugin(),
  31. ],
  32. };
  33. }
  34. },
  35. chainWebpack: (config) => {
  36. if (process.env.NODE_ENV === 'production') {
  37. config.plugin('loadshReplace').use(new LodashModuleReplacementPlugin());
  38. }
  39. },
  40. devServer: {
  41. port: '8001',
  42. inline: true,
  43. proxy: {
  44. '/files': {
  45. target: 'http://baoan.fwedzgc.com:8090',
  46. },
  47. '/api': {
  48. target: 'http://baoan.fwedzgc.com:8090',
  49. changeOrigin: true,
  50. ws: false,
  51. },
  52. },
  53. },
  54. };