rspack.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const path = require('path');
  2. const isCI = process.env.CI === 'true';
  3. const isSCM = !!process.env.BUILD_BRANCH;
  4. const isProd = process.env.NODE_ENV === 'production';
  5. /**
  6. * @type {import('@rspack/cli').Configuration}
  7. */
  8. module.exports = {
  9. mode: process.env.NODE_ENV,
  10. context: __dirname,
  11. target: ['web'],
  12. entry: {
  13. main: './src/app.tsx',
  14. },
  15. builtins: {
  16. // https://www.rspack.dev/config/builtins.html#builtinshtml
  17. html: [
  18. {
  19. template: './index.html',
  20. },
  21. ],
  22. progress: !isSCM ? {} : false,
  23. treeShaking: isProd,
  24. },
  25. module: {
  26. // https://www.rspack.dev/config/module.html#rule
  27. rules: [
  28. {
  29. test: /\.(png|gif|jpg|jpeg|svg|woff2)$/,
  30. type: 'asset',
  31. },
  32. ],
  33. },
  34. plugins: [],
  35. /** module is too large now, we may need better way to tackle this in the future */
  36. stats: isCI
  37. ? { all: false, modules: true, assets: true, chunks: true, warnings: true, errors: true }
  38. : {
  39. modules: false,
  40. all: false,
  41. warnings: false,
  42. errors: true,
  43. timings: true,
  44. },
  45. };