Skip to content

Commit 0e09780

Browse files
authored
Add ability to overwrite the outputPath (Webpack only)
1 parent d3e4749 commit 0e09780

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ The following options are available for the Faro JavaScript bundler plugins:
124124
- `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
125125
- `appId: string` *required*: The ID of your application, it should match the `appId` value used in your Faro Web SDK configuration
126126
- `stackId: string` *required*: The ID of the stack, found in Frontend Observability under **Settings** and **Web SDK Config**
127+
- `outputPath: string` *optional*: Folder where output files will be located
127128
- `outputFiles: string[]` *optional*: An array of source map files to upload, by default Faro uploads all source maps
128129
- `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
129130
- `keepSourcemaps: boolean` *optional*: Whether to keep the source maps in your generated bundle after uploading, default `false`

packages/faro-bundlers-shared/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface FaroSourceMapUploaderPluginOptions {
1010
appId: string;
1111
apiKey: string;
1212
stackId: string;
13+
outputPath?: string;
1314
outputFiles?: string[];
1415
bundleId?: string;
1516
keepSourcemaps?: boolean;

packages/faro-webpack/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class FaroSourceMapUploaderPlugin
2626
private stackId: string;
2727
private endpoint: string;
2828
private bundleId: string;
29+
private outputPathOverride?: string;
2930
private outputFiles?: string[];
3031
private keepSourcemaps?: boolean;
3132
private gzipContents?: boolean;
@@ -36,6 +37,7 @@ export default class FaroSourceMapUploaderPlugin
3637
this.apiKey = options.apiKey;
3738
this.stackId = options.stackId;
3839
this.endpoint = `${options.endpoint}/app/${options.appId}/sourcemaps/`;
40+
this.outputPathOverride = options.outputPath;
3941
this.outputFiles = options.outputFiles;
4042
this.bundleId = options.bundleId ?? String(Date.now() + randomString(5));
4143
this.keepSourcemaps = options.keepSourcemaps;
@@ -49,7 +51,7 @@ export default class FaroSourceMapUploaderPlugin
4951
*/
5052
apply(compiler: webpack.Compiler): void {
5153
const BannerPlugin = compiler.webpack.BannerPlugin;
52-
const outputPath = compiler.options.output.path;
54+
const outputPath = this.outputPathOverride ?? compiler.options.output.path;
5355

5456
compiler.options.plugins = compiler.options.plugins || [];
5557
compiler.options.plugins.push(

0 commit comments

Comments
 (0)