More page updates
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
// What it does:
|
||||
// 1. Bundles + minifies JS (entry: assets/js/main.js) -> dist/assets/bundle.min.js
|
||||
// 2. Resolves CSS @imports + minifies -> dist/assets/bundle.min.css
|
||||
// 3. Copies index.html / about.html to dist/, rewriting script+link tags
|
||||
// 3. Copies index.html / about.html / faq.html to dist/, rewriting script+link tags
|
||||
// 4. Copies static files (images, robots.txt, sitemap.xml)
|
||||
//
|
||||
// Dev files are NEVER touched. Deploy from dist/ for production.
|
||||
@@ -37,6 +37,7 @@ function cleanDist() {
|
||||
path.join(ASSETS, 'bundle.min.css'),
|
||||
path.join(DIST, 'index.html'),
|
||||
path.join(DIST, 'about.html'),
|
||||
path.join(DIST, 'faq.html'),
|
||||
path.join(ASSETS, '_tmp_flat.css'),
|
||||
path.join(ASSETS, 'about.min.css'),
|
||||
];
|
||||
@@ -68,11 +69,16 @@ function bumpVersion() {
|
||||
}
|
||||
|
||||
// Swap dev asset tags in HTML for bundle tags.
|
||||
// Strips the main sunscope.css link but preserves standalone CSS files
|
||||
// like about.css that are not part of the main bundle.
|
||||
// Strips the main sunscope.css link, rewrites standalone about.css to
|
||||
// about.min.css with a version param, and injects the JS bundle.
|
||||
function rewriteHTML(html, version) {
|
||||
html = html.replace(/<link\s[^>]*href=["'][^"']*assets\/sunscope\.css[^"']*["'][^>]*>/gi, '');
|
||||
html = html.replace(/<script\s[^>]*src=["'][^"']*assets\/js\/[^"']*["'][^>]*><\/script>/gi, '');
|
||||
// Rewrite standalone about.css reference to versioned minified file.
|
||||
html = html.replace(
|
||||
/(<link\s[^>]*href=["'][^"']*assets\/)about\.css(["'][^>]*>)/gi,
|
||||
'$1about.min.css?v=' + version + '$2'
|
||||
);
|
||||
const css = ' <link rel="stylesheet" href="./assets/bundle.min.css?v=' + version + '">';
|
||||
const js = ' <script defer src="./assets/bundle.min.js?v=' + version + '"></script>';
|
||||
html = html.replace('</head>', css + '\n' + js + '\n</head>');
|
||||
@@ -138,7 +144,7 @@ async function build() {
|
||||
// 4. Process HTML files
|
||||
console.log(' Processing HTML...');
|
||||
const version = bumpVersion();
|
||||
for (const htmlFile of ['index.html', 'about.html']) {
|
||||
for (const htmlFile of ['index.html', 'about.html', 'faq.html']) {
|
||||
const src = path.join(ROOT, htmlFile);
|
||||
if (!fs.existsSync(src)) continue;
|
||||
const updated = rewriteHTML(fs.readFileSync(src, 'utf8'), version);
|
||||
|
||||
Reference in New Issue
Block a user