webpack.chartcuterie.config.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* eslint-env node */
  2. /* eslint import/no-nodejs-modules:0 */
  3. import childProcess from 'child_process';
  4. import path from 'path';
  5. import webpack from 'webpack';
  6. import baseConfig from '../webpack.config';
  7. const commitHash =
  8. process.env.SENTRY_BUILD ||
  9. childProcess.execSync('git rev-parse HEAD').toString().trim();
  10. const findLoader = (loaderName: string) =>
  11. baseConfig.module?.rules?.find(
  12. rule =>
  13. rule &&
  14. typeof rule === 'object' &&
  15. typeof rule.use === 'object' &&
  16. !Array.isArray(rule.use) &&
  17. rule.use.loader === loaderName
  18. ) as webpack.RuleSetRule;
  19. const config: webpack.Configuration = {
  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('babel-loader'), findLoader('po-catalog-loader')],
  29. noParse: baseConfig.module?.noParse,
  30. },
  31. plugins: [
  32. new webpack.DefinePlugin({
  33. 'process.env': {COMMIT_SHA: JSON.stringify(commitHash)},
  34. }),
  35. ],
  36. output: {
  37. path: path.join(__dirname, 'chartcuterie'),
  38. libraryTarget: 'commonjs2',
  39. },
  40. optimization: {minimize: false},
  41. };
  42. module.exports = config;