Skip to content

Support ignore pattern from config #5

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ To install, add the following lines to your **netlify.toml** file:
```toml
[[plugins]]
package = "netlify-plugin-amp-server-side-rendering"
[plugins.inputs]
ignorePattern = "public/admin/*"
```

[1]: https://amp.dev/
3 changes: 3 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
name: netlify-plugin-amp-server-side-rendering
inputs:
- name: ignorePattern
description: Ignore pattern
15 changes: 11 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ const fs = require('fs');
const glob = require('glob');

module.exports = {
onPostBuild: async ({ constants, utils }) => {
onPostBuild: async ({ inputs, constants, utils }) => {
const pattern = constants.PUBLISH_DIR + '/**/*.html';
const options = {
nodir: true
}

if (inputs.ignorePattern) {
options.ignore = inputs.ignorePattern
}

const files = await new Promise((resolve, reject) => {
glob(pattern, { nodir: true }, (err, files) => {
(err) ? reject(err) : resolve(files);
glob(pattern, options, (err, files) => {
(err) ? reject(err): resolve(files);
});
});

Expand All @@ -25,4 +32,4 @@ module.exports = {
summary: `Successfully rendered ${files.length} file(s).`
});
}
};
};