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

Catch all script? #17

Open
markpinero opened this issue Jan 26, 2021 · 3 comments
Open

Catch all script? #17

markpinero opened this issue Jan 26, 2021 · 3 comments

Comments

@markpinero
Copy link

markpinero commented Jan 26, 2021

Hi, is there a way to have pattern matching for scripts with all pages along with page-specific code? IE:

{
  '*': './src/js/index.js',
  '/about': './src/js/about.js'
}
@amannn
Copy link
Owner

amannn commented Jan 26, 2021

Hello @markpinero,

that's a good idea. Currently you should be able to configure a wildcard to match all pages, but only one client script will be injected at a time.

That's this section in the code:

const match = clientScriptsByPathRegex.find((cur) =>
cur.pathRegex.test(pagePath)
);
if (!match) {
return null;
}
return (
<script async={async} src={match.clientScript} type={type} {...rest} />
);

I guess if you'd adapt that to render a script tag for every matched client script, you could get this working.

Would you be interested in contributing this feature?

@markpinero
Copy link
Author

Yes, I would love to give it a shot.

@amannn
Copy link
Owner

amannn commented Jan 26, 2021

Great, let me know how it goes!

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

2 participants