Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrong committed Jul 9, 2024
1 parent 8dca3e4 commit cbe41d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions react/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ RUN <<EOF
yarn build
/app/tools/install.sh
NODE_PATH=$(npm root --quiet -g) node /app/tools/index.js /app/source/out
NODE_PATH=$(npm root --quiet -g) node /app/after.js /app/source/out
EOF

FROM ikrong/mini-http:latest
Expand Down
21 changes: 21 additions & 0 deletions react/after.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require("fs");
const path = require("path");
const fetch = require("node-fetch");
const cheerio = require("cheerio");
const glob = require("glob").globSync;

const HOST_DIR = process.argv[2];

!(() => {
const matchFiles = glob(path.join(HOST_DIR, "./**/*.js"));
for (const file of matchFiles) {
let content = fs.readFileSync(file).toString();
const reg = /['"]https:\/\/(react\.dev\/fonts\/[\s\S]+?)['"]/g
if (reg.test(content)) {
content = content.replace(reg, (_, path) => {
return `"/cdn-resource-cached/${path}"`;
})
fs.writeFileSync(file, content);
}
}
})();

0 comments on commit cbe41d5

Please sign in to comment.