rsbuild.config.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { defineConfig, loadEnv } from '@rsbuild/core'
  2. import { createRsbuildPlugins } from './config/plugins/index'
  3. // import proxy from './config/proxy'
  4. const { publicVars, parsed } = loadEnv({
  5. prefixes: ['VUE_APP_'],
  6. })
  7. const isBuild = process.env.NODE_ENV === 'production'
  8. const shouldDropConsole = !parsed.VUE_APP_DROP_CONSOLE
  9. ? isBuild
  10. : parsed.VUE_APP_DROP_CONSOLE === 'true'
  11. export default defineConfig({
  12. /* 入口文件 */
  13. source: {
  14. entry: {
  15. index: './src/main',
  16. },
  17. /* 注入环境变量 */
  18. define: publicVars,
  19. },
  20. html: {
  21. template: 'public/index.html',
  22. title: parsed.VUE_APP_TITLE,
  23. },
  24. server: {
  25. port: 9906,
  26. // proxy: {
  27. // '/v1/admin': {
  28. // target: 'http://192.168.10.31:8080',
  29. // changeOrigin: true,
  30. // },
  31. // },
  32. },
  33. tools: {
  34. rspack: {
  35. ignoreWarnings: [/Conflicting order/],
  36. experiments: {
  37. nativeWatcher: true,
  38. },
  39. },
  40. },
  41. plugins: createRsbuildPlugins(isBuild),
  42. output: {
  43. polyfill: 'entry',
  44. cleanDistPath: isBuild,
  45. legalComments: 'none',
  46. },
  47. performance: {
  48. printFileSize: {
  49. compressed: false,
  50. },
  51. /* 打包时候移除console */
  52. removeConsole: shouldDropConsole,
  53. },
  54. splitChunks: {
  55. preset: 'default',
  56. maxInitialSize: 3000 * 1024,
  57. },
  58. })