vue.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. chainWebpack: config => {
  25. // 移除 prefetch 插件
  26. config.plugins.delete('preload');
  27. config.plugins.delete('prefetch');
  28. config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
  29. },
  30. configureWebpack: {
  31. //性能提示
  32. performance: {
  33. hints: false
  34. },
  35. optimization: {
  36. splitChunks: {
  37. chunks: "all",
  38. automaticNameDelimiter: '~',
  39. name: "scuiChunks",
  40. cacheGroups: {
  41. //第三方库抽离
  42. vendor: {
  43. name: "modules",
  44. test: /[\\/]node_modules[\\/]/,
  45. priority: -10
  46. },
  47. elicons: {
  48. name: "elicons",
  49. test: /[\\/]node_modules[\\/]@element-plus[\\/]icons-vue[\\/]/
  50. },
  51. tinymce: {
  52. name: "tinymce",
  53. test: /[\\/]node_modules[\\/]tinymce[\\/]/
  54. },
  55. echarts: {
  56. name: "echarts",
  57. test: /[\\/]node_modules[\\/]echarts[\\/]/
  58. },
  59. xgplayer: {
  60. name: "xgplayer",
  61. test: /[\\/]node_modules[\\/]xgplayer.*[\\/]/
  62. },
  63. codemirror: {
  64. name: "codemirror",
  65. test: /[\\/]node_modules[\\/]codemirror[\\/]/
  66. }
  67. }
  68. }
  69. }
  70. }
  71. })