rspack.chartcuterie.config.ts 1.2 KB

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