webpack.chartcuterie.config.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. 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;