Skip to content

Exclude files in .zip except those with a bang ! #1510

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

Open
5 tasks done
skube opened this issue Mar 9, 2025 · 6 comments · May be fixed by #1517
Open
5 tasks done

Exclude files in .zip except those with a bang ! #1510

skube opened this issue Mar 9, 2025 · 6 comments · May be fixed by #1517
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug

Comments

@skube
Copy link
Contributor

skube commented Mar 9, 2025

Describe the bug

Asking the AI bot about excluding files from zip, I got these instructions:

To exclude all JSON files except manifest.json from the zip, you can configure the zip.exclude option in your wxt.config.ts file as follows:

// wxt.config.ts
import { defineConfig } from 'wxt';

export default defineConfig({
  zip: {
    exclude: [
      '**/*.json',       // Exclude all .json files
      '!manifest.json',  // Include manifest.json
    ],
  },
});

Here's how this configuration works:

    '**/*.json' excludes all files with the .json extension in any directory.
    '!manifest.json' is a negative pattern that includes manifest.json, overriding the previous exclusion.

Make sure that the paths specified in the exclude array are relative to the root of the WXT project.

However, the bang(!) seems to cause some weirdness when trying to open the produced zip file.

Not sure if I'm doing something wrong, or if there is a bug?

Reproduction

https://github.com/skube/min-repro-wxt

Steps to reproduce

Steps:

  1. npm i
  2. npm run zip
  3. Try to open .zip created in .output/

System Info

System:
    OS: macOS 15.3.1
    CPU: (8) arm64 Apple M2
    Memory: 107.06 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.12.2 - ~/.nvm/versions/node/v20.11.1/bin/pnpm
    bun: 1.2.2 - ~/.bun/bin/bun
  Browsers:
    Chrome: 133.0.6943.142
    Edge: 118.0.2088.76
    Safari: 18.3
  npmPackages:
    wxt: ^0.19.29 => 0.19.29

Used Package Manager

npm

Validations

@skube skube added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Mar 9, 2025
@nishu-murmu
Copy link
Contributor

In source code we're excluding all the matches after pattern matching so you need to include (in pattern matching) in order to actually exclude it.
Image

for example:
you want exclude manifest.json file in your zip
you need to write something like
exclude: ['**/*.json', 'manifest.json'],
instead of
exclude: ['**/*.json', '!manifest.json'],

@skube
Copy link
Contributor Author

skube commented Mar 10, 2025

Thanks for investigating @nishu-murmu, however when I try
exclude: ['**/*.json', 'manifest.json'],
There still is no manifest.json in the resulting .zip file.

@skube skube changed the title Exclude file from .zip with bang ! Include file from .zip with bang ! Mar 10, 2025
@skube skube changed the title Include file from .zip with bang ! Include file in .zip with bang ! Mar 10, 2025
@nishu-murmu
Copy link
Contributor

You changed the title, first you've written Exclude now you want to Include. 🙃
It was really confusing.

@skube
Copy link
Contributor Author

skube commented Mar 10, 2025

Yes, because I realized the title was confusing after re-reading. (I'm not even sure it is less confusing now 🥴)

However, it was mentioned in the copy

To exclude all JSON files except manifest.json from the zip,...

Sorry for the confusion!

@skube skube changed the title Include file in .zip with bang ! Exclude files in .zip except those with a bang ! Mar 10, 2025
@nishu-murmu
Copy link
Contributor

nishu-murmu commented Mar 11, 2025

Okay, yeah we can do this. but do we need to actually implement this type of behaviour @aklinker1 cause in docs it is mentioned that exclude parameter will also accept minimatch's pattern matching functionality apart from relative paths as well.

If you want this I can create PR for this.

Image

@aklinker1
Copy link
Collaborator

Yup, sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants