webpack.chartcuterie.config.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import childProcess from 'node:child_process';
  2. import path from 'node:path';
  3. import webpack from 'webpack';
  4. import baseConfig from '../webpack.config';
  5. const commitHash =
  6. process.env.SENTRY_BUILD ||
  7. childProcess.execSync('git rev-parse HEAD').toString().trim();
  8. const findLoader = (loaderName: string) =>
  9. baseConfig.module?.rules?.find(
  10. rule =>
  11. rule &&
  12. typeof rule === 'object' &&
  13. typeof rule.use === 'object' &&
  14. !Array.isArray(rule.use) &&
  15. rule.use.loader === loaderName
  16. ) as webpack.RuleSetRule;
  17. const config: webpack.Configuration = {
  18. mode: baseConfig.mode,
  19. context: baseConfig.context,
  20. resolve: baseConfig.resolve,
  21. target: 'node',
  22. entry: {
  23. config: 'sentry/chartcuterie/config',
  24. },
  25. module: {
  26. rules: [findLoader('babel-loader'), findLoader('po-catalog-loader')],
  27. noParse: baseConfig.module?.noParse,
  28. },
  29. plugins: [
  30. new webpack.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. };
  40. module.exports = config;