vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. //设置为空打包后不分更目录还是多级目录
  4. publicPath:'',
  5. //build编译后存放静态文件的目录
  6. //assetsDir: "static",
  7. // build编译后不生成资源MAP文件
  8. productionSourceMap: false,
  9. //开发服务,build后的生产模式还需nginx代理
  10. devServer: {
  11. allowedHosts: 'all',
  12. open: false, //运行后自动打开浏览器
  13. port: process.env.VUE_APP_PORT, //挂载端口
  14. proxy: {
  15. '/api': {
  16. target: process.env.VUE_APP_API_BASEURL,
  17. ws: true,
  18. pathRewrite: {
  19. '^/api': '/'
  20. }
  21. }
  22. }
  23. },
  24. lintOnSave: false,
  25. chainWebpack: config => {
  26. // 移除 prefetch 插件
  27. config.plugins.delete('preload');
  28. config.plugins.delete('prefetch');
  29. config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
  30. },
  31. configureWebpack: {
  32. //性能提示
  33. performance: {
  34. hints: false
  35. },
  36. optimization: {
  37. splitChunks: {
  38. chunks: "all",
  39. automaticNameDelimiter: '~',
  40. name: "scuiChunks",
  41. cacheGroups: {
  42. //第三方库抽离
  43. vendor: {
  44. name: "modules",
  45. test: /[\\/]node_modules[\\/]/,
  46. priority: -10
  47. },
  48. elicons: {
  49. name: "elicons",
  50. test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
  51. },
  52. tinymce: {
  53. name: "tinymce",
  54. test: /[\\/]node_modules[\\/]tinymce[\\/]/
  55. },
  56. echarts: {
  57. name: "echarts",
  58. test: /[\\/]node_modules[\\/]echarts[\\/]/
  59. },
  60. xgplayer: {
  61. name: "xgplayer",
  62. test: /[\\/]node_modules[\\/]xgplayer.*[\\/]/
  63. },
  64. codemirror: {
  65. name: "codemirror",
  66. test: /[\\/]node_modules[\\/]codemirror[\\/]/
  67. }
  68. }
  69. }
  70. }
  71. }
  72. })