rspack.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. resolve: {
  16. alias: {
  17. react: require.resolve('react'),
  18. 'react-dom': require.resolve('react-dom'),
  19. },
  20. },
  21. builtins: {
  22. // https://www.rspack.dev/config/builtins.html#builtinshtml
  23. html: [
  24. {
  25. template: './index.html',
  26. },
  27. ],
  28. progress: !isSCM ? {} : false,
  29. treeShaking: isProd,
  30. },
  31. module: {
  32. // https://www.rspack.dev/config/module.html#rule
  33. rules: [
  34. {
  35. test: /\.(png|gif|jpg|jpeg|svg|woff2)$/,
  36. type: 'asset',
  37. },
  38. {
  39. test: /\.(less|css)$/,
  40. use: [
  41. {
  42. loader: 'less-loader',
  43. options: {
  44. // ...
  45. },
  46. },
  47. ],
  48. type: 'css',
  49. },
  50. ],
  51. },
  52. plugins: [],
  53. /** module is too large now, we may need better way to tackle this in the future */
  54. stats: isCI
  55. ? { all: false, modules: true, assets: true, chunks: true, warnings: true, errors: true }
  56. : {
  57. modules: false,
  58. all: false,
  59. warnings: false,
  60. errors: true,
  61. timings: true,
  62. },
  63. };