vue.config.js 2.0 KB

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