vue.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. const webpack = require('webpack')
  2. const packageName = 'qmxSubApp'
  3. module.exports = {
  4. publicPath: '/qmx_page_admin',
  5. outputDir: "qmx_page_admin",
  6. productionSourceMap: false,
  7. lintOnSave: false,
  8. css: {
  9. loaderOptions: {
  10. sass: {
  11. // 静默 `legacy-js-api` 和 `@import` 警告
  12. sassOptions: {
  13. silenceDeprecations: ['legacy-js-api', 'import', 'global-builtin']
  14. },
  15. prependData: `@import '@/assets/css/_variables.scss';`
  16. }
  17. }
  18. },
  19. configureWebpack: {
  20. // devtool: 'source-map',
  21. output: {
  22. library: 'qmxSubApp',
  23. libraryTarget: 'umd',
  24. jsonpFunction: `webpackJsonp_${packageName}`
  25. },
  26. plugins: [
  27. new webpack.ProvidePlugin({
  28. $:"jquery",
  29. jQuery:"jquery",
  30. "windows.jQuery":"jquery"
  31. })
  32. ],
  33. optimization: {
  34. splitChunks: {
  35. chunks: 'all', // 对所有类型的chunk进行分割
  36. minSize: 40 * 8 * 1024, // 分割前模块的最小大小(字节)
  37. maxSize: 200 * 8 * 1024, // 尝试将大于此大小的块分割成较小的部分
  38. minChunks: 2, // 分割前模块的最小被引用次数
  39. maxInitialRequests: 20,// 入口点的最大并行请求数
  40. automaticNameDelimiter: '.', // 生成的名称分隔符
  41. cacheGroups: {
  42. // 自定义缓存组
  43. vendors: {
  44. test: /[\\/]node_modules[\\/]/,
  45. priority: -10,
  46. name: 'vendors'
  47. },
  48. default: {
  49. minChunks: 2,
  50. priority: -20,
  51. reuseExistingChunk: true,
  52. name: 'common'
  53. },
  54. }
  55. },
  56. },
  57. },
  58. chainWebpack: (config) => {
  59. const fontRule = config.module.rule('fonts');
  60. fontRule.uses.clear();
  61. fontRule
  62. .use('file-loader')
  63. .loader('file-loader')
  64. .options({
  65. name: 'fonts/[name].[hash:8].[ext]',
  66. publicPath: process.env.NODE_ENV === 'production' ? '/qmx_page_admin' : '',
  67. })
  68. .end();
  69. },
  70. devServer: {
  71. // open: false,
  72. // client: {
  73. // overlay: {
  74. // errors: true,
  75. // warnings: false
  76. // }
  77. // },
  78. // // historyApiFallback: true,
  79. // allowedHosts: 'all',
  80. proxy: {
  81. '^/dev-api': {
  82. target: 'https://web2-qmx_admin.jydev.jianyu360.com',
  83. changeOrigin: true,
  84. ws: false,
  85. logLevel: 'debug',
  86. pathRewrite: {
  87. '^/dev-api': '/api/admin/'
  88. }
  89. },
  90. '^/bigmember': {
  91. target: 'https://jybx2-webtest.jydev.jianyu360.com',
  92. changeOrigin: true,
  93. ws: false,
  94. logLevel: 'debug',
  95. pathRewrite: {
  96. '^/bigmember': '/bigmember'
  97. }
  98. },
  99. '^/filemanage': {
  100. target: 'https://web2-qmx_admin.jydev.jianyu360.com',
  101. changeOrigin: true,
  102. ws: false,
  103. logLevel: 'debug',
  104. pathRewrite: {
  105. '^/filemanage': '/filemanage'
  106. }
  107. },
  108. '^/jyOrderManager': {
  109. target: 'https://jybx2-webtest.jydev.jianyu360.com',
  110. changeOrigin: true,
  111. ws: false,
  112. logLevel: 'debug',
  113. },
  114. '^/succbi': {
  115. target: 'https://web2-qmx_admin.jydev.jianyu360.com',
  116. changeOrigin: true,
  117. ws: false,
  118. logLevel: 'debug'
  119. }
  120. }
  121. }
  122. }