vue.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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: 3008,
  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. '/upload/': {
  22. target: 'http://192.168.0.45:9002'
  23. }
  24. }
  25. },
  26. configureWebpack: {
  27. output: {
  28. library: `${packageName}-[name]`,
  29. libraryTarget: 'umd',
  30. jsonpFunction: `webpackJsonp_${packageName}`
  31. },
  32. resolve: {
  33. alias: {
  34. '@components': path.join(frameSrc, '/src/components'),
  35. '@style': path.join(frameSrc, '/style'),
  36. '@lib': path.join(frameSrc, '/lib')
  37. }
  38. },
  39. plugins: [
  40. new CompressionWebpackPlugin({
  41. filename: '[path].gz[query]',
  42. algorithm: 'gzip',
  43. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  44. threshold: 10240,
  45. minRatio: 0.8
  46. })
  47. ]
  48. }
  49. };