Skip to content

Commit

Permalink
(chore) fix CDN build
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Apr 22, 2021
1 parent 4bed963 commit a8a291a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tools/build_cdn.js
@@ -1,4 +1,5 @@
const fs = require("fs").promises;
const fss = require("fs");
const glob = require("glob");
const zlib = require('zlib');
const { getLanguages } = require("./lib/language");
Expand All @@ -11,8 +12,8 @@ const { buildPackageJSON } = require("./build_node");
const path = require("path");
const bundling = require('./lib/bundling.js');

async function installPackageJSON() {
await buildPackageJSON();
async function installPackageJSON(options) {
await buildPackageJSON(options);
const json = require(`${process.env.BUILD_DIR}/package`);
json.name = "@highlightjs/cdn-assets";
json.description = json.description.concat(" (pre-compiled CDN assets)");
Expand All @@ -24,7 +25,7 @@ let shas = {};
async function buildCDN(options) {
install("./LICENSE", "LICENSE");
install("./README.CDN.md", "README.md");
installPackageJSON();
installPackageJSON(options);

installStyles();

Expand Down Expand Up @@ -104,9 +105,12 @@ async function installLanguages(languages) {

function installStyles() {
log("Writing style files.");
mkdir("styles");
mkdir("styles/base16");

glob.sync("**", { cwd: "./src/styles" }).forEach((file) => {
const stat = fss.statSync(`./src/styles/${file}`);
if (stat.isDirectory()) return;

glob.sync("*", { cwd: "./src/styles" }).forEach((file) => {
if (file.endsWith(".css")) {
installCleanCSS(`./src/styles/${file}`, `styles/${file.replace(".css", ".min.css")}`);
} else {
Expand Down

0 comments on commit a8a291a

Please sign in to comment.