rspack.prod.config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { defineConfig } from '@rspack/cli';
  2. import { rspack } from '@rspack/core';
  3. import { baseConfig } from './rspack.base.config';
  4. export default defineConfig({
  5. ...baseConfig,
  6. mode: 'production',
  7. entry: {
  8. main: './src/main.ts',
  9. },
  10. devtool: false,
  11. output: {
  12. clean: true,
  13. filename: '[name].[contenthash].js',
  14. chunkFilename: '[name].[contenthash].js',
  15. },
  16. optimization: {
  17. minimize: true,
  18. minimizer: [
  19. new rspack.SwcJsMinimizerRspackPlugin(),
  20. new rspack.LightningCssMinimizerRspackPlugin(),
  21. ],
  22. splitChunks: {
  23. chunks: 'async',
  24. minChunks: 1,
  25. minSize: 2000,
  26. maxAsyncRequests: 30,
  27. maxInitialRequests: 30,
  28. cacheGroups: {
  29. 'vue-router': {
  30. name: 'vue-router',
  31. test: /[\\/]node_modules[\\/]vue-router[\\/]/,
  32. priority: 120,
  33. chunks: 'all',
  34. reuseExistingChunk: true,
  35. },
  36. vue: {
  37. name: 'vue',
  38. test: /[\\/]node_modules[\\/]vue[\\/]/,
  39. priority: 200,
  40. chunks: 'all',
  41. reuseExistingChunk: true,
  42. },
  43. axios: {
  44. name: 'axios',
  45. test: /[\\/]node_modules[\\/]axios[\\/]/,
  46. priority: 9,
  47. chunks: 'all',
  48. reuseExistingChunk: true,
  49. },
  50. defaultVendors: {
  51. test: /[\\/]node_modules[\\/]/,
  52. priority: -10,
  53. reuseExistingChunk: true,
  54. },
  55. default: {
  56. minChunks: 2,
  57. priority: -20,
  58. reuseExistingChunk: true,
  59. },
  60. },
  61. },
  62. },
  63. experiments: {
  64. css: true,
  65. },
  66. });