Use local built KaTeX on the main page for local and Netlify deploy preview (#1631)

* Use local built KaTeX on the main page for local and netlify builds

* Use KaTeX from CDN on Netlify production deploy
This commit is contained in:
ylemkimon
2018-09-04 07:25:29 +09:00
committed by GitHub
parent 48e5a26ee9
commit c8f8ebd880
3 changed files with 18 additions and 7 deletions

View File

@@ -11,6 +11,16 @@ ${option.description}${((option.bool && option.defaultValue !== undefined)
`),
'### `-h, --help`\nOutput usage information', ''].join('\n'));
// copy local built CSS and fonts
// copy local built KaTeX
fs.copySync('../dist/katex.min.js', 'static/static/katex.min.js');
fs.copySync('../dist/katex.min.css', 'static/static/katex.min.css');
fs.copySync('../dist/fonts', 'static/static/fonts');
// use KaTeX from CDN on the main page for Netlify production deploy
if (process.env.CONTEXT === 'production') {
const version = require('../versions.json')[0];
let indexHtml = fs.readFileSync('pages/index.html', 'utf8');
indexHtml = indexHtml.replace(/(["'])static\/(katex|fonts)/g,
`$1https://cdn.jsdelivr.net/npm/katex@${version}/dist/$2`);
fs.writeFileSync('pages/index.html', indexHtml);
}