Skip to content

Commit

Permalink
feat: allow excluding files when zipping (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeraa authored Aug 8, 2024
1 parent 0ab32e5 commit cbda49b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/wxt/src/core/utils/building/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ function resolveZipConfig(
includeSources: [],
compressionLevel: 9,
...mergedConfig.zip,
exclude: mergedConfig.zip?.exclude ?? [],
excludeSources: [
'**/node_modules',
// WXT files
Expand Down
1 change: 1 addition & 0 deletions packages/wxt/src/core/utils/testing/fake-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export const fakeResolvedConfig = fakeObjectCreator<ResolvedConfig>(() => {
artifactTemplate: '{{name}}-{{version}}.zip',
includeSources: [],
excludeSources: [],
exclude: [],
sourcesRoot: fakeDir(),
sourcesTemplate: '{{name}}-sources.zip',
name: faker.person.firstName().toLowerCase(),
Expand Down
4 changes: 3 additions & 1 deletion packages/wxt/src/core/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export async function zip(config?: InlineConfig): Promise<string[]> {

const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
const outZipPath = path.resolve(wxt.config.outBaseDir, outZipFilename);
await zipDir(wxt.config.outDir, outZipPath);
await zipDir(wxt.config.outDir, outZipPath, {
exclude: wxt.config.zip.exclude,
});
zipFiles.push(outZipPath);

// ZIP sources for Firefox
Expand Down
11 changes: 11 additions & 0 deletions packages/wxt/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ export interface InlineConfig {
* ]
*/
excludeSources?: string[];
/**
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
* zipping the extension.
*
* @example
* [
* "**\/*.map", // Exclude all sourcemaps
* ]
*/
exclude?: string[];
/**
* The Firefox review process requires the extension be buildable from source to make reviewing
* easier. This field allows you to use private packages without exposing your auth tokens.
Expand Down Expand Up @@ -1192,6 +1202,7 @@ export interface ResolvedConfig {
downloadedPackagesDir: string;
downloadPackages: string[];
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
exclude: string[];
};
/**
* @deprecated Use `build:manifestGenerated` hook instead.
Expand Down

0 comments on commit cbda49b

Please sign in to comment.