Skip to content

Commit

Permalink
(chore)package CDN for NPM
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 1, 2020
1 parent ddd34a4 commit 6006a80
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
45 changes: 45 additions & 0 deletions README.CDN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Highlight.js CDN Assets

[![install size](https://packagephobia.now.sh/badge?p=highlight.js)](https://packagephobia.now.sh/result?p=highlight.js)

**This package contains only the CDN build assets of highlight.js.**

This may be what you want if you'd like to install the pre-built distributable highlight.js client-side assets via NPM. If you're wanting to use highlight.js mainly on the server-side you likely want the [highlight.js][1] package instead.

To access these files via CDN:<br>
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/

**If you just want a single .js file with the common languages built-in:
<https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/highlight.min.js>**

---

## Highlight.js

Highlight.js is a syntax highlighter written in JavaScript. It works in
the browser as well as on the server. It works with pretty much any
markup, doesn’t depend on any framework, and has automatic language
detection.

If you'd like to read the full README:<br>
<https://github.com/highlightjs/highlight.js/blob/master/README.md>

## License

Highlight.js is released under the BSD License. See [LICENSE][7] file
for details.

## Links

The official site for the library is at <https://highlightjs.org/>.

The Github project may be found at: <https://github.com/highlightjs/highlight.js>

Further in-depth documentation for the API and other topics is at
<http://highlightjs.readthedocs.io/>.

Authors and contributors are listed in the [AUTHORS.txt][8] file.

[1]: https://www.npmjs.com/package/highlight.js
[7]: https://github.com/highlightjs/highlight.js/blob/master/LICENSE
[8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.txt
11 changes: 10 additions & 1 deletion tools/build_cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ const config = require("./build_config");
const { install, install_cleancss, mkdir } = require("./lib/makestuff");
const log = (...args) => console.log(...args);
const { buildBrowserHighlightJS } = require("./build_browser");
const { buildPackageJSON } = require("./build_node");
const path = require("path");

async function installPackageJSON() {
await buildPackageJSON();
let json = require(`${process.env.BUILD_DIR}/package`);
json.name = "highlight.js-cdn-assets";
fs.writeFile(`${process.env.BUILD_DIR}/package.json`, JSON.stringify(json, null, ' '));
}

async function buildCDN(options) {
install("./LICENSE", "LICENSE");
install("./README.md","README.md");
install("./README.CDN.md","README.md");
installPackageJSON();

installStyles();

Expand Down
3 changes: 2 additions & 1 deletion tools/build_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function buildPackageJSON() {
}
return acc;
}, []);
fs.writeFile(`${process.env.BUILD_DIR}/package.json`, JSON.stringify(json, null, ' '));
await fs.writeFile(`${process.env.BUILD_DIR}/package.json`, JSON.stringify(json, null, ' '));
}

async function buildLanguages(languages) {
Expand Down Expand Up @@ -100,3 +100,4 @@ async function buildNode(options) {
}

module.exports.build = buildNode;
module.exports.buildPackageJSON = buildPackageJSON;

0 comments on commit 6006a80

Please sign in to comment.