集成后台重构版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. 'use strict'
  2. const path = require('path')
  3. const defaultSettings = require('./src/settings.js')
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. const name = defaultSettings.title // 网址标题
  8. const port = 8013 // 端口配置
  9. module.exports = {
  10. // hash 模式下可使用
  11. // publicPath: process.env.NODE_ENV === 'development' ? '/' : './',
  12. publicPath: '/',
  13. outputDir: 'dist',
  14. assetsDir: 'static',
  15. lintOnSave: process.env.NODE_ENV === 'development',
  16. productionSourceMap: false,
  17. devServer: {
  18. port: port,
  19. open: true,
  20. overlay: {
  21. warnings: false,
  22. errors: true
  23. },
  24. proxy: {
  25. '/api': {
  26. target: process.env.VUE_APP_BASE_API,
  27. changeOrigin: true,
  28. pathRewrite: {
  29. '^/api': 'api'
  30. }
  31. },
  32. '/auth': {
  33. target: process.env.VUE_APP_BASE_API,
  34. changeOrigin: true,
  35. pathRewrite: {
  36. '^/auth': 'auth'
  37. }
  38. }
  39. }
  40. },
  41. configureWebpack: {
  42. name: name,
  43. resolve: {
  44. alias: {
  45. '@': resolve('src'),
  46. '@crud': resolve('src/components/Crud')
  47. }
  48. }
  49. },
  50. chainWebpack(config) {
  51. config.plugins.delete('preload') // TODO: need test
  52. config.plugins.delete('prefetch') // TODO: need test
  53. // set svg-sprite-loader
  54. config.module
  55. .rule('svg')
  56. .exclude.add(resolve('src/assets/icons'))
  57. .end()
  58. config.module
  59. .rule('icons')
  60. .test(/\.svg$/)
  61. .include.add(resolve('src/assets/icons'))
  62. .end()
  63. .use('svg-sprite-loader')
  64. .loader('svg-sprite-loader')
  65. .options({
  66. symbolId: 'icon-[name]'
  67. })
  68. .end()
  69. // set preserveWhitespace
  70. config.module
  71. .rule('vue')
  72. .use('vue-loader')
  73. .loader('vue-loader')
  74. .tap(options => {
  75. options.compilerOptions.preserveWhitespace = true
  76. return options
  77. })
  78. .end()
  79. config.when(process.env.NODE_ENV === 'development', config =>
  80. config.devtool('cheap-source-map')
  81. )
  82. config.when(process.env.NODE_ENV !== 'development', config => {
  83. config
  84. .plugin('ScriptExtHtmlWebpackPlugin')
  85. .after('html')
  86. .use('script-ext-html-webpack-plugin', [
  87. {
  88. inline: /runtime\..*\.js$/
  89. }
  90. ])
  91. .end()
  92. config.optimization.splitChunks({
  93. chunks: 'all',
  94. cacheGroups: {
  95. libs: {
  96. name: 'chunk-libs',
  97. test: /[\\/]node_modules[\\/]/,
  98. priority: 10,
  99. chunks: 'initial'
  100. },
  101. elementUI: {
  102. name: 'chunk-elementUI',
  103. priority: 20,
  104. test: /[\\/]node_modules[\\/]_?element-ui(.*)/
  105. },
  106. commons: {
  107. name: 'chunk-commons',
  108. test: resolve('src/components'),
  109. minChunks: 3,
  110. priority: 5,
  111. reuseExistingChunk: true
  112. }
  113. }
  114. })
  115. config.optimization.runtimeChunk('single')
  116. })
  117. },
  118. transpileDependencies: ['vue-echarts', 'resize-detector']
  119. }