vue.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const path = require('path');
  2. const frameSrc = path.resolve(__dirname, '../admin-frame');
  3. const packageName = require('./package.json').name;
  4. const CompressionWebpackPlugin = require('compression-webpack-plugin');
  5. // 定义压缩文件类型
  6. const productionGzipExtensions = ['js', 'css'];
  7. module.exports = {
  8. publicPath: `/${packageName}/`,
  9. outputDir: path.join(frameSrc, `../../admin-web/${packageName}/`),
  10. devServer: {
  11. port: 3026,
  12. headers: {
  13. 'Access-Control-Allow-Origin': '*'
  14. },
  15. proxy: {
  16. '/api/': {
  17. // target: 'http://192.168.0.45:18090'
  18. target: 'http://192.168.3.45:18090'
  19. }
  20. }
  21. },
  22. configureWebpack: {
  23. output: {
  24. library: `${packageName}-[name]`,
  25. libraryTarget: 'umd',
  26. jsonpFunction: `webpackJsonp_${packageName}`
  27. },
  28. resolve: {
  29. alias: {
  30. '@components': path.join(frameSrc, '/src/components'),
  31. '@style': path.join(frameSrc, '/style'),
  32. '@lib': path.join(frameSrc, '/lib')
  33. }
  34. },
  35. plugins: [
  36. new CompressionWebpackPlugin({
  37. filename: '[path].gz[query]',
  38. algorithm: 'gzip',
  39. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  40. threshold: 10240,
  41. minRatio: 0.8
  42. })
  43. ]
  44. }
  45. };