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

Ignore files based on VCS ignore files (like .gitignore) or using a custom ignore files (.wextignore) #940

Open
ntninja opened this issue May 6, 2017 · 9 comments

Comments

@ntninja
Copy link

ntninja commented May 6, 2017

Is this a feature request or a bug?

Feature Request

What is the current behavior?

web-ext build ignores files based on a hard-coded default list and whatever you pass to --ignore-files.

What is the expected or desired behavior?

Ideally the ignore files of different VCS systems (like GIT's .gitignore) should be honoured when running web-ext build or (alternatively or additionally) web-ext builld should read ignore patterns from a separate ignore file (.wextignore?) and apply those automatically on build as well.

.

If this is something that web-ext will want to support? If so please tell me which way you feel comfortable with and I'll probably implement it.

@kumar303
Copy link
Contributor

kumar303 commented May 6, 2017

Hi, thanks for filing the issue. Since we already have an --ignore-files option I think the best way forward is to finish implementing config file support so that you could put a web-ext-config.js file in your current directory (or in ~/.web-ext-config.js) and add your rules to it like this:

module.exports = {
  ignoreFiles: [
    '*.data', 
    '*.pdf', 
    '...',
  ],
};

If you take a look at the tracker issue I linked to you will see that config file support is almost ready but currently we don't have someone working on it. If you are able to work on any of the remaining issues I can mentor the work and review patches. Thanks for your interest!

@Croydon
Copy link

Croydon commented Oct 1, 2017

This is a rather citrical feature in my humble opinion, so I would really love to see some progress on this issue :)

@kumar303
Copy link
Contributor

kumar303 commented Oct 2, 2017

I agree, sorry about the delay. The config file approach is actually in progress right now. The latest patch is close to landing (see #1080) but there are still a few more that will need to land before the feature is usable. Thanks to @saintsebastian for helping on this!

@mz8i
Copy link

mz8i commented May 27, 2019

Hi, is there any news on this feature? Has it been implemented?

@Rob--W
Copy link
Member

Rob--W commented May 27, 2019

@mz8i Although not literally the same as the syntax of .gitignore, it is already possible to exclude files via a web-ext-config.js as explained in #940 (comment)

Example:

// web-ext-config.js
module.exports = {
  ignoreFiles: [
    "web-ext-config.js",
    // .. more files here. globs are supported too
  ],
};

Example:

# ls
background.js  contentscript.js  manifest.json  web-ext-config.js
# web-ext build
Applying config files: ~/.web-ext-config.js, ./web-ext-config.js
Building web extension from /tmp/yow
Your web extension is ready: /tmp/example/web-ext-artifacts/name_of_example-1.zip
# unzip -l web-ext-artifacts/name_of_example-1.zip
Archive:  web-ext-artifacts/name_of_example-1.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2019-05-27 18:00   contentscript.js
        0  2019-05-27 18:00   background.js
      467  2019-05-27 18:00   manifest.json
---------                     -------
      467                     3 files

Note: When the --ignore-files parameter is set, the contents of the config file are completely ignored. So do not use them together; either set ignoreFiles in your config file, or specify all ignores at the --ignore-files command-line parameter.

@stokito
Copy link

stokito commented Sep 27, 2019

Thank you @Rob--W
It also would be great to document the feature: I spent a lot of time to find the recipe

@kumar303
Copy link
Contributor

@stokito sorry for that. Config files are documented here but they are a generic solution for setting defaults on any option so maybe it wasn't obvious to look there.

What part of the docs were you looking in? Maybe we should add an explicit note in --ignore-files?

@stokito
Copy link

stokito commented Sep 27, 2019

Oh, now I see, thank you :) I just didn't get to the bottom of the page. I never created an extension but I already had sources of some extension and I wanted to fix it a little bit and run and test locally. The order in which I learned:

  1. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension from there I clicked on "Publishing your extension".
  2. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Package_your_extension_ and from there I opened "web-ext tool" link
  3. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference#web-ext_build here I was confused because this is a full reference and I didn't know how to start but I found a link "web-ext documentation"
  4. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Getting_started_with_web-ext now it's what I looked for: I quickly installed it and made web-ext run and afterwards executed web-ext build. But then I struggled on the problem with ignored files because the resulted bundle contains README,md file and some others.
    So I started to search the way to exclude those files.

But I saw the --ignore-files option in reference and yes, it would be great to mention it there. Maybe even earlier in quick start tutorial.

@s4my
Copy link

s4my commented Apr 19, 2024

Since we already have an --ignore-files option I think the best way forward is to finish implementing config file support so that you could put a web-ext-config.js file in your current directory (or in ~/.web-ext-config.js)

I still think if I already have the list of files that should be ignored in my .gitignore, it's redundant to have the same list in a configuration file. And now I have to keep both lists in sync.

By the way, is it possible to specify a different source (i.e. --source-dir) or destination (i.e., --artifacts-dir) directory in the configuration file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants