This upgrades currently used version 10.0.2 from May 2020. Build process is amended to use terser minification, as it provides better result as closure-compiler: [1] Terser (5.3.8): $ ls -all build/highlight.min.js -rw-r--r-- 1 davido users 977775 Jan 10 10:04 build/highlight.min.js Closure-Compiler (v20210106): $ ls -all build/highlight.min.js -rw-r--r-- 1 davido users 994034 Jan 9 12:10 build/highlight.min.js So, terser produces minified build that is 16259 bytes smaller. Moreover, in latest gerrit releases terser is also used for gr-app.js minification, so it appears to be consistent to also use terser for highlight.js minification. [1] https://github.com/highlightjs/highlight.js/issues/2956 Change-Id: I3a67dc05eb9c4fdac1bf578eacd777dfefb2a360
1.2 KiB
1.2 KiB
Building Highlight.js for Gerrit
Highlight JS needs to be built with specific language support. Here are the steps to build the minified file that appears here.
NOTE: If you are adding support for a language to Highlight.js make sure to add it to the list of languages in the build command below.
Prerequisites
You will need:
- nodejs
- closure-compiler
- git
Steps to Create the Pack File
The packed version of Highlight.js is an un-minified JS file with all of the languages included. Build it with the following:
$> # start in some temp directory
$> git clone https://github.com/highlightjs/highlight.js
$> cd highlight.js
$> git clone https://github.com/highlightjs/highlightjs-closure-templates
$> ln -s ../../highlightjs-closure-templates/soy.js src/languages/soy.js
$> mkdir test/detect/soy && ln -s ../../../highlightjs-closure-templates/test/detect/soy/default.txt test/detect/soy/default.txt
$> npm install
$> node tools/build.js
The resulting minified JS file will appear in the "build" directory of the Highlight.js repo under the name "highlight.min.js".
Finish
Copy the resulting build/highlight.min.js file to lib/highlightjs