vue.config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const path = require('path')
  2. const sass = require('sass')
  3. const { defineConfig } = require('@vue/cli-service')
  4. const settings = require('./src/config')
  5. const isDev = process.env.NODE_ENV === 'development'
  6. function resolve(dir) {
  7. return path.join(__dirname, dir)
  8. }
  9. module.exports = defineConfig({
  10. publicPath: settings.contextPath,
  11. outputDir: 'jxc-admin',
  12. assetsDir: 'static',
  13. runtimeCompiler: true,
  14. lintOnSave: false,
  15. productionSourceMap: false,
  16. transpileDependencies: false,
  17. css: {
  18. loaderOptions: {
  19. css: {
  20. modules: {
  21. auto: /var.scss$/
  22. }
  23. },
  24. sass: {
  25. // https://github.com/sass/dart-sass/issues/1388#issuecomment-916125648
  26. sassOptions: {
  27. outputStyle: 'expanded',
  28. logger: sass.Logger.silent
  29. }
  30. }
  31. }
  32. },
  33. configureWebpack: {
  34. name: settings.title,
  35. resolve: {
  36. alias: {
  37. '@': resolve('src'),
  38. '@ele': resolve('element-ui-personal')
  39. }
  40. },
  41. devServer: {
  42. port: process.env.port || 8079,
  43. client: {
  44. overlay: {
  45. warnings: true,
  46. errors: true
  47. }
  48. },
  49. proxy: {
  50. [settings.apiPrefix]: {
  51. target: 'https://infojxc.info666.com/api',
  52. ws:false,
  53. secure: false,
  54. changeOrigin: true,
  55. }
  56. }
  57. }
  58. },
  59. chainWebpack(config) {
  60. config.plugins.delete('preload')
  61. config.plugins.delete('prefetch')
  62. // set svg-sprite-loader
  63. config
  64. .module
  65. .rule('svg')
  66. .exclude.add(resolve('src/asset/icon'))
  67. .end()
  68. config
  69. .module
  70. .rule('icons')
  71. .test(/\.svg$/)
  72. .include.add(resolve('src/asset/icon'))
  73. .end()
  74. .use('svg-sprite-loader')
  75. .loader('svg-sprite-loader')
  76. .options({ symbolId: 'icon-[name]' })
  77. .end()
  78. config.when(!isDev, config => {
  79. //将css合并到一个文件中
  80. //https://github.com/vuejs/vue-cli/issues/2843
  81. config
  82. .optimization
  83. .removeEmptyChunks(true)
  84. .splitChunks({
  85. cacheGroups: {
  86. style: {
  87. name: 'style',
  88. type: 'css/mini-extract',
  89. chunks: 'all'
  90. }
  91. }
  92. })
  93. .end()
  94. })
  95. }
  96. })