next-client-script icon indicating copy to clipboard operation
next-client-script copied to clipboard

Catch all script?

Open markpinero opened this issue 4 years ago • 3 comments

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'
}

markpinero avatar Jan 26 '21 06:01 markpinero

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:

https://github.com/amannn/next-client-script/blob/de5ed6ffc9284e436764da076396515f13e859fe/packages/next-client-script/src/ClientScript.tsx#L25-L35

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?

amannn avatar Jan 26 '21 06:01 amannn

Yes, I would love to give it a shot.

markpinero avatar Jan 26 '21 17:01 markpinero

Great, let me know how it goes!

amannn avatar Jan 26 '21 17:01 amannn