mozilla / web-ext

A command line tool to help build, run, and test web extensions
Mozilla Public License 2.0
2.66k stars 334 forks source link

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

Open ntninja opened 7 years ago

ntninja commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

kumar303 commented 6 years ago

I agree, sorry about the delay. The config file approach is actually in progress right now. The latest patch is close to landing (see https://github.com/mozilla/web-ext/pull/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 commented 5 years ago

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

Rob--W commented 5 years ago

@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 https://github.com/mozilla/web-ext/issues/940#issuecomment-299659633

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 commented 4 years ago

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

kumar303 commented 4 years ago

@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 commented 4 years ago

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 commented 4 months ago

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?