Automatically downloaded customised files
See original GitHub issueMotivation The feature where you can minify the code by selecting which languages you need support for before clicking ‘download’ is nice, but it would be great to do this automatically (e.g. to add to build tools).
Clicking the relevant checkboxes on the website generates a URL like https://prismjs.com/download.html#themes=prism-funky&languages=markup+css+clike+javascript+haskell+protobuf+purebasic
And we can evidently automatically create this URL. But then the “Download JS” and “Download CSS” buttons have to be pressed manually to trigger the actual download.
Description And endpoint or similar where I could download the CSS and JS files from a customised URL directly e.g.
Alternatives Visiting the website manually or trying to reverse engineer the javascript that triggers the download button.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Instead of an npm task, we could also do a simple CLI. This could be used like this:
We could also use a configuration file (maybe similar to this format?) instead of CLI arguments or both.
Yeah, the script does a bunch of things…
The actual build process is quite easy. We just take the list of languages/plugins the user selected, pass it to
getLoader
, and get a sorted list of ids from that. We then concatenate all JS/CSS files (see thepath
attribute (each category has one)) of the sorted list of ids (in order) and that’s the final output.(It also has to include
prism-core.js
and the actual theme. We also have to handle that only some plugins have CSS files.)That’s the basics of what the build process is. Right now at least. It will be able to do more after #2162.
I also want to add that
components.json
, while required bygetLoader
, is not part of the public API and we might change the layout of the object at any time.