Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@redhat-cloud-services/frontend-components-config-utilities": "^4.7.1",
"@redhat-cloud-services/tsc-transform-imports": "^1.0.26",
"@sentry/webpack-plugin": "^4.5.0",
"@swc/core": "^1.3.76",
"assert": "^2.0.0",
"axios": "^1.12.2",
Expand Down
40 changes: 40 additions & 0 deletions packages/config/src/lib/createPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,29 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
const { glob } = require('glob');
const path = require('path');

export type WebpackPluginDefinition = undefined | null | false | '' | 0 | ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;

export interface SentryConfig {
org: string;
project: string;
release?: string;
urlPrefix?: string;
include?: string;
ignore?: string[];
inject?: boolean;
cleanArtifacts?: boolean;
rewrite?: boolean;
}

export interface CreatePluginsOptions extends CommonConfigOptions {
generateSourceMaps?: boolean;
plugins?: WebpackPluginDefinition[];
definePlugin?: Record<string, any>;
initSentry?: SentryConfig;
}

export const createPlugins = ({
Expand All @@ -26,6 +40,7 @@ export const createPlugins = ({
_unstableHotReload,
hotReload,
useFileHash = true,
initSentry,
}: CreatePluginsOptions) => {
if (!rootFolder) {
fecLogger(LogType.error, 'rootFolder is required attribute for the createPlugins function!');
Expand Down Expand Up @@ -68,6 +83,31 @@ export const createPlugins = ({
...(hasTsConfig ? [new ForkTsCheckerWebpackPlugin()] : []),
...(plugins || []),
...(internalHotReload ? [new ReactRefreshWebpackPlugin()] : []),
// Put the sentry plugin at the end of the plugins array
...(process.env.ENABLE_SENTRY && initSentry
? [
sentryWebpackPlugin({
...(process.env.SENTRY_AUTH_TOKEN && {
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
org: initSentry.org,
project: initSentry.project,
release: process.env.SENTRY_RELEASE,
urlPrefix: initSentry.urlPrefix,
include: initSentry.include,
ignore: initSentry.ignore,
inject: initSentry.inject,
cleanArtifacts: initSentry.cleanArtifacts ,
rewrite: initSentry.rewrite ,
moduleMetadata: ({ release }: { release: string }) => ({
dsn: process.env.SENTRY_DSN,
org: initSentry.org,
project: initSentry.project,
release,
}),
}),
]
: []),
];
};

Expand Down