rspack.chartcuterie.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-env node */
  2. import type {Configuration, RuleSetRule} from '@rspack/core';
  3. import rspack from '@rspack/core';
  4. import childProcess from 'node:child_process';
  5. import path from 'node:path';
  6. import baseConfig from '../rspack.config';
  7. const commitHash =
  8. process.env.SENTRY_BUILD ||
  9. childProcess.execSync('git rev-parse HEAD', {encoding: 'utf8'}).trim();
  10. // @ts-ignore
  11. const findLoader = (loaderName: string) =>
  12. baseConfig.module?.rules?.find(
  13. (rule: any) =>
  14. rule &&
  15. typeof rule === 'object' &&
  16. (rule.loader === loaderName || rule.use?.loader === loaderName)
  17. ) as RuleSetRule;
  18. export default {
  19. mode: baseConfig.mode,
  20. context: baseConfig.context,
  21. resolve: baseConfig.resolve,
  22. target: 'node',
  23. entry: {
  24. config: 'sentry/chartcuterie/config',
  25. },
  26. module: {
  27. rules: [findLoader('builtin:swc-loader'), findLoader('po-catalog-loader')],
  28. },
  29. plugins: [
  30. new rspack.DefinePlugin({
  31. 'process.env.COMMIT_SHA': JSON.stringify(commitHash),
  32. }),
  33. ],
  34. output: {
  35. path: path.join(__dirname, 'chartcuterie'),
  36. libraryTarget: 'commonjs2',
  37. },
  38. optimization: {minimize: false},
  39. } as Configuration;