webpack.chartcuterie.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* eslint-env node */
  2. import childProcess from 'node:child_process';
  3. import path from 'node:path';
  4. import webpack from 'webpack';
  5. import baseConfig from '../webpack.config';
  6. const commitHash =
  7. process.env.SENTRY_BUILD ||
  8. childProcess.execSync('git rev-parse HEAD').toString().trim();
  9. const findLoader = (loaderName: string) =>
  10. baseConfig.module?.rules?.find(
  11. rule =>
  12. rule &&
  13. typeof rule === 'object' &&
  14. typeof rule.use === 'object' &&
  15. !Array.isArray(rule.use) &&
  16. rule.use.loader === loaderName
  17. ) as webpack.RuleSetRule;
  18. const config: webpack.Configuration = {
  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('babel-loader'), findLoader('po-catalog-loader')],
  28. noParse: baseConfig.module?.noParse,
  29. },
  30. plugins: [
  31. new webpack.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. };
  41. module.exports = config;