集成后台重构版本
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.

160 lines
4.6 KiB

3 years ago
3 years ago
3 years ago
  1. 'use strict'
  2. //基本项目配置
  3. const path = require('path')
  4. const defaultSettings = require('./src/settings.js')
  5. //项目路径
  6. function resolve(dir) {
  7. return path.join(__dirname, dir)
  8. }
  9. // 网址标题
  10. const name = defaultSettings.title
  11. // 端口配置
  12. const port = 8013
  13. //代理配置
  14. module.exports = {
  15. // hash 模式下可使用
  16. // publicPath: process.env.NODE_ENV === 'development' ? '/' : './',
  17. //部署应用包时的基本 URL
  18. publicPath: '/',
  19. //当运行 vue-cli-service build 时生成的生产环境构建文件的目录
  20. outputDir: 'dist',
  21. //放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
  22. assetsDir: 'static',
  23. //是否在开发环境下通过 eslint-loader 在每次保存时 lint 代码
  24. lintOnSave: process.env.NODE_ENV === 'development',
  25. //不需要生产环境构建source map,方便输出的错误信息
  26. productionSourceMap: false,
  27. devServer: {
  28. //配置服务器端口设置
  29. port: port,
  30. //告诉 dev-server 在服务器已经启动后打开浏览器。设置其为 true 以打开你的默认浏览器。
  31. open: true,
  32. //当出现编译错误或警告时,在浏览器中显示全屏覆盖。
  33. overlay: {
  34. warnings: false,
  35. errors: true
  36. },
  37. //开发代理服务设置
  38. proxy: {
  39. '/api': {
  40. //代理目标路径
  41. target: process.env.VUE_APP_BASE_API,
  42. //保留主机头的来源
  43. changeOrigin: true,
  44. //路径规则
  45. pathRewrite: {
  46. '^/api': 'api'
  47. }
  48. },
  49. '/auth': {
  50. target: process.env.VUE_APP_BASE_API,
  51. changeOrigin: true,
  52. pathRewrite: {
  53. '^/auth': 'auth'
  54. }
  55. }
  56. }
  57. },
  58. //调试VUE
  59. configureWebpack: {
  60. devtool: 'source-map'
  61. }
  62. // configureWebpack: {
  63. // // 覆盖webpack默认配置的都在这里
  64. // name: name,
  65. // resolve: {
  66. // alias: {
  67. // '@': resolve('src'),
  68. // '@crud': resolve('src/components/Crud')
  69. // },
  70. // chainWebpack(config) {
  71. // config.plugins.delete('preload')
  72. // config.plugins.delete('prefetch')
  73. // // set svg-sprite-loader
  74. // config.module
  75. // .rule('svg')
  76. // .exclude.add(resolve('src/assets/icons'))
  77. // .end()
  78. // config.module
  79. // .rule('icons')
  80. // .test(/\.svg$/)
  81. // .include.add(resolve('src/assets/icons'))
  82. // .end()
  83. // .use('svg-sprite-loader')
  84. // .loader('svg-sprite-loader')
  85. // .options({
  86. // symbolId: 'icon-[name]'
  87. // })
  88. // .end()
  89. // // set preserveWhitespace
  90. // config.module
  91. // .rule('vue')
  92. // .use('vue-loader')
  93. // .loader('vue-loader')
  94. // .tap(options => {
  95. // options.compilerOptions.preserveWhitespace = true
  96. // return options
  97. // })
  98. // .end()
  99. // config
  100. // .when(process.env.NODE_ENV === 'development',
  101. // config => config.devtool('cheap-source-map')
  102. // )
  103. // config
  104. // .when(process.env.NODE_ENV !== 'development',
  105. // config => {
  106. // config
  107. // .plugin('ScriptExtHtmlWebpackPlugin')
  108. // .after('html')
  109. // .use('script-ext-html-webpack-plugin', [{
  110. // inline: /runtime\..*\.js$/
  111. // }])
  112. // .end()
  113. // config
  114. // .optimization.splitChunks({
  115. // chunks: 'all',
  116. // cacheGroups: {
  117. // libs: {
  118. // name: 'chunk-libs',
  119. // test: /[\\/]node_modules[\\/]/,
  120. // priority: 10,
  121. // chunks: 'initial'
  122. // },
  123. // elementUI: {
  124. // name: 'chunk-elementUI',
  125. // priority: 20,
  126. // test: /[\\/]node_modules[\\/]_?element-ui(.*)/
  127. // },
  128. // commons: {
  129. // name: 'chunk-commons',
  130. // test: resolve('src/components'),
  131. // minChunks: 3,
  132. // priority: 5,
  133. // reuseExistingChunk: true
  134. // }
  135. // }
  136. // })
  137. // config.optimization.runtimeChunk('single')
  138. // }
  139. // )
  140. // },
  141. // transpileDependencies: [
  142. // 'vue-echarts',
  143. // 'resize-detector'
  144. // ]
  145. // }
  146. // }
  147. }