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

how to ignore a folder? #5

Closed
fizzydigital opened this issue Aug 6, 2015 · 13 comments
Closed

how to ignore a folder? #5

fizzydigital opened this issue Aug 6, 2015 · 13 comments

Comments

@fizzydigital
Copy link

Here's my metalsmith.json:

"metalsmith-ignore": [

    "less/**",
    "less",

]

It ignores all *.less files, but still copies less/ directory into the build folder.

Here are all the patterns I tried so far:

[

    "less/**/*.less",
    "less/*",
    "less/**/*",
    "less/",
    "less",
    "./less"

]

Any suggestions?

@oupala
Copy link

oupala commented Aug 31, 2015

I had the exact same problem as you.

You might have invisible dotfile in your less directory. If you also delete dotfiles, it should work.

Here is my (working) configuration:

        .use(ignore([ // use ignore as soon as possible is important as it lowers the build time
            'js/bootstrap/**', // ignore bootstrap files
            'js/bootstrap/**/.*' // ignore bootstrap hidden files
        ]))

Hope this helps!

@ninjasort
Copy link

I'm also confused about this. It doesn't appear very semantic to use a glob if you simply want to ignore a directory entirely. Ideally we could just put the folder name:

.use(ignore([
    'directory'
]))

@oupala
Copy link

oupala commented Jan 11, 2016

In other words, you must explicitly ignore hidden files in addition to the directory if you want to ignore an entire directory that contains hidden file.

@danicholls
Copy link

Thanks, @oupala. 👍

@julkue
Copy link

julkue commented Apr 8, 2016

Why not just use Metalsmith(__dirname).ignore("folder")? Taken from the docs.

@oupala
Copy link

oupala commented Apr 29, 2016

Thanks @julmot for this interesting suggestion. I tried it just now and did not managed to make it work.

I replaced this:

.use(ignore([
    'images/logo.svg'
]))

by this:

.ignore(
  'images/logo.svg'
)

And my logo.svg file is no more ignored.

@julkue
Copy link

julkue commented Apr 29, 2016

@oupala The .ignore() function will search relative from the source directory (.source(dir)). Are you sure that you aren't referencing from the metalsmith file? Also, .ignore() accepts an array too. So you don't need to replace it with a single string.

@oupala
Copy link

oupala commented May 2, 2016

I think I am correctly referencing the file (as the source dir is src):

.source('./src/')
$ ls -l src/images/logo.svg 
-rw-r--r-- 1 myuser myuser 4694 juil.  2  2015 src/images/logo.svg

By the way, I'm also using arrays when I need to ignore more than one item.

@julkue
Copy link

julkue commented May 2, 2016

@oupala For me, it works like a charm.

@oupala
Copy link

oupala commented May 2, 2016

Well, for me, it really doesn't... :-)

Does anyone has an idea about why it doesn't work in some cases, and which ones?

I had a look at the official documentation about ignore and I found nothing special about this feature.

One last question, if metalsmith-ignore can be easily replaced by the ignore function of metalsmith, why would the same company - Segment - develop both of them? Is there some particular feature in metalsmith-ignore that one can't find in metalsmith ?

@julkue
Copy link

julkue commented May 2, 2016

@oupala Did you tried other filenames? Can you please post your full code that is necessary to execute Metalsmith?

Regarding your question, I think this plugin still exists due to compatibility reasons. However, it should still be mentioned in the README of this repository that it is not necessary anymore. But I think that this company has shown, that even if there are very much open issues for years now, they created it because of self-interest.

@oupala
Copy link

oupala commented May 3, 2016

When using ignore, it appears that we can use full path to the file. We need to use the ** prefix.

These syntaxes works:

.ignore([
      '**/src/images/logo.svg'
])
.ignore([
      '**/images/logo.svg'
])
.ignore([
      '**/logo.svg'
])
.ignore([
      'logo.svg'
])

But it seems that - if you wan to add some dir in the path - the path must be prepended by **.

Is there a way to specify a path relative to the source directory? Something like:

.ignore([
      'images/logo.svg'
])

or

.ignore([
      'src/images/logo.svg'
])

@marcoms
Copy link

marcoms commented May 5, 2016

Thanks @oupala for that, ignoring a directory now works for me!

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