Switch to Vite
driesvints opened this issue · 2 comments
Similar to laravelio/laravel.io#882
Started work on this and found an issue where highlightjs-line-numbers.js
doesn't work with Vite's ES6 modules. This is due to it being restricted to CommonJS (wcoder/highlightjs-line-numbers.js#78).
A potential workaround is using a CDN like Cloudflare and loading it after app.js
where the plugin can access hljs
on the window like it's designed. Or switching to another open-source free code highlighter like Prism.
Any recommendations on which avenue to pursue?
Found a third option I found is to create an intermediate JavaScript file in resources/js
that imports highlightjs-line-numbers.js
that gets resolved after app.js
in its own <script>
tag. This has the same effect as using the CDN it's just it uses the npm version instead.