vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. proxy: {
  43. '/files': {
  44. target: 'http://broadcast.waityou24.cn',
  45. },
  46. '/groupBuy/api': {
  47. target: 'http://192.168.223.1:14000',
  48. changeOrigin: true,
  49. },
  50. '/wechat/api': {
  51. target: 'http://192.168.223.1:14001',
  52. changeOrigin: true,
  53. },
  54. '/ws': {
  55. target: 'http://101.36.221.66',
  56. ws: false,
  57. },
  58. },
  59. },
  60. };