vue.config.js 1.3 KB

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