use "jsdelivr" to host file
From the official features page of jsdelivr, we know that jsDelivr provides mirrors for npm, GitHub, WordPress plugins, and custom endpoints for several other projects with special requirements.
We will go through the
The detail steps:
- Create a new repository named
- Author the relevant css file named
md.csswhich content can be found in serve a css file for markdown preview in VSCode.
- Git Push to Github.
- The cdn URL should be
- The file path is only specific for my case, change your path or name if necessary.
- If you don’t use the
<commit-hash>way, cdn will cache your css file which will result in confusion if you change you css and push again. There is no hook to purge the cache on cdn now. Except for this, I think this way is easier than
Instead of creating a repository on Github, you should publish a package on npmjs.com.
And in addition to authoring the css file, you should provide the entry point file
index.js at the root directory of your package and import the css file.
Then, the cdn URL should be
Note: Publishing updated packages will be rejected if you don’t change your package version, so it’s no cache problem mentioned above.