Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternate outputPath #13

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The following options are available for the Faro JavaScript bundler plugins:
- `apiKey: string` *required*: The API key for your Faro Collector, you can generate a new scope on [grafana.com], refer to the [Obtaining API key](#obtaining-api-key) section
- `appId: string` *required*: The ID of your application, it should match the `appId` value used in your Faro Web SDK configuration
- `stackId: string` *required*: The ID of the stack, found in Frontend Observability under **Settings** and **Web SDK Config**
- `outputPath: string` *optional*: Folder where output files will be located
- `outputFiles: string[]` *optional*: An array of source map files to upload, by default Faro uploads all source maps
- `bundleId: string` *optional*: The ID of the bundle/build, by default auto-generated, or specify an ID to filter by bundle ID in Frontend Observability
- `keepSourcemaps: boolean` *optional*: Whether to keep the source maps in your generated bundle after uploading, default `false`
Expand Down
1 change: 1 addition & 0 deletions packages/faro-bundlers-shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface FaroSourceMapUploaderPluginOptions {
appId: string;
apiKey: string;
stackId: string;
outputPath?: string;
outputFiles?: string[];
bundleId?: string;
keepSourcemaps?: boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/faro-webpack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class FaroSourceMapUploaderPlugin
private stackId: string;
private endpoint: string;
private bundleId: string;
private outputPathOverride?: string;
private outputFiles?: string[];
private keepSourcemaps?: boolean;
private gzipContents?: boolean;
Expand All @@ -36,6 +37,7 @@ export default class FaroSourceMapUploaderPlugin
this.apiKey = options.apiKey;
this.stackId = options.stackId;
this.endpoint = `${options.endpoint}/app/${options.appId}/sourcemaps/`;
this.outputPathOverride = options.outputPath;
this.outputFiles = options.outputFiles;
this.bundleId = options.bundleId ?? String(Date.now() + randomString(5));
this.keepSourcemaps = options.keepSourcemaps;
Expand All @@ -49,7 +51,7 @@ export default class FaroSourceMapUploaderPlugin
*/
apply(compiler: webpack.Compiler): void {
const BannerPlugin = compiler.webpack.BannerPlugin;
const outputPath = compiler.options.output.path;
const outputPath = this.outputPathOverride ?? compiler.options.output.path;

compiler.options.plugins = compiler.options.plugins || [];
compiler.options.plugins.push(
Expand Down
Loading