itmayziii / gatsby-plugin-no-javascript

Removes all javascript files created by Gatsby from the static HTML files.
MIT License
77 stars 13 forks source link

Need mutiple paths for excluding paths or files #14

Open ptrobert opened 4 years ago

ptrobert commented 4 years ago

Need multiple paths for excluding paths or files

We need the ability to exclude multiple paths like partners, contactus etc

ptrobert commented 4 years ago

can we pass some thing like this currently { resolve:gatsby-plugin-no-javascript, options:{ excludePaths:'/contactus', excludePaths:'/partners', } }

itmayziii commented 4 years ago

@ptrobert

Thank you for the feedback, I will look at implementing this feature tonight.

city41 commented 4 years ago

I just discovered this plugin (thanks for making it!). From what I can tell, excludePaths is used like a regex, similar to excludeFiles. So I think @ptrobert you can get what you are after with excludePaths: '(/contactus|/partners)'

The README says excludePaths is an array of strings, but I don't think that is correct.

ahmadkhalaf1 commented 3 years ago

@city41 Hello , can you please tell me how can i use this excludePaths , lets say i have a page www.mysite.de/foo/bar/

and i only want to keep JS for this page only in my website , is this possible? i tried


 {
      resolve: 'gatsby-plugin-no-javascript',
      options: {
        excludePaths: '/foo',
         // excludePaths: 'foo',
        //  excludePaths: '/foo/bar',
        // excludePaths: '/foo/bar/',
      },
    }

    but seems like its not working .
mykeels commented 2 years ago

Here's an example of using multiple values in excludePaths:

{
  resolve: "gatsby-plugin-no-javascript",
  options: {
    excludePaths: [
      "blog/(index.+)?$",
      "404",
      "error",
      "support/?$",
      "contact/?$"
    ]
    .map(path => `(${path})`)
    .join("|")
  }
}