dev #13
@@ -109,20 +109,21 @@ async function createOptimizedBuild() {
|
|||||||
})
|
})
|
||||||
]).process(combinedCSS, { from: undefined });
|
]).process(combinedCSS, { from: undefined });
|
||||||
|
|
||||||
await fs.writeFile('dist/css/styles.css', minifiedCSS.css);
|
// Combine with custom site styles
|
||||||
|
|
||||||
// Also minify custom site styles
|
|
||||||
const customCSS = await fs.readFile('public/site-styles/style.css', 'utf8');
|
const customCSS = await fs.readFile('public/site-styles/style.css', 'utf8');
|
||||||
const minifiedCustomCSS = await postcss([
|
const combinedWithCustomCSS = minifiedCSS.css + '\n' + customCSS;
|
||||||
|
|
||||||
|
// Minify the combined CSS bundle
|
||||||
|
const finalMinifiedCSS = await postcss([
|
||||||
cssnano({
|
cssnano({
|
||||||
preset: ['default', {
|
preset: ['default', {
|
||||||
discardComments: { removeAll: true },
|
discardComments: { removeAll: true },
|
||||||
normalizeWhitespace: true
|
normalizeWhitespace: true
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
]).process(customCSS, { from: undefined });
|
]).process(combinedWithCustomCSS, { from: undefined });
|
||||||
|
|
||||||
await fs.writeFile('dist/site-styles/style.css', minifiedCustomCSS.css);
|
await fs.writeFile('dist/css/bundle.css', finalMinifiedCSS.css);
|
||||||
|
|
||||||
// Step 3: JavaScript Bundling and Minification
|
// Step 3: JavaScript Bundling and Minification
|
||||||
console.log('📦 Step 3: Bundling and minifying JavaScript...');
|
console.log('📦 Step 3: Bundling and minifying JavaScript...');
|
||||||
@@ -148,9 +149,9 @@ async function createOptimizedBuild() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate compression results
|
// Calculate compression results
|
||||||
const originalCSSSize = (await fs.stat('public/css/pico.green.min.css')).size +
|
const originalCSSSize = (await fs.stat('public/css/pico.jade.min.css')).size +
|
||||||
(await fs.stat('public/css/pico.colors.min.css')).size;
|
(await fs.stat('public/css/pico.min.css')).size;
|
||||||
const optimizedCSSSize = (await fs.stat('dist/css/styles.css')).size;
|
const optimizedCSSSize = (await fs.stat('dist/css/bundle.css')).size;
|
||||||
const cssReduction = ((originalCSSSize - optimizedCSSSize) / originalCSSSize * 100).toFixed(1);
|
const cssReduction = ((originalCSSSize - optimizedCSSSize) / originalCSSSize * 100).toFixed(1);
|
||||||
|
|
||||||
const originalHTMLSize = (await fs.stat('public/index.html')).size +
|
const originalHTMLSize = (await fs.stat('public/index.html')).size +
|
||||||
@@ -271,10 +272,9 @@ async function minifyHTMLFile(inputPath, outputPath) {
|
|||||||
|
|
||||||
// Update CSS references for production and add script reference
|
// Update CSS references for production and add script reference
|
||||||
let updatedHTML = html
|
let updatedHTML = html
|
||||||
.replace(/<link rel="stylesheet" href="css\/pico\.green\.min\.css">/g, '')
|
.replace(/<link rel="stylesheet" href="css\/pico\.jade\.min\.css">/g, '')
|
||||||
.replace(/<link rel="stylesheet" href="css\/pico\.colors\.min\.css">/g, '')
|
|
||||||
.replace(/<link rel="stylesheet" href="site-styles\/style\.css">/g,
|
.replace(/<link rel="stylesheet" href="site-styles\/style\.css">/g,
|
||||||
'<link rel="stylesheet" href="css/styles.css"><link rel="stylesheet" href="site-styles/style.css">')
|
'<link rel="stylesheet" href="css/bundle.css">')
|
||||||
.replace(/<\/body>/g, '<script src="scripts/bundle.js"></script></body>');
|
.replace(/<\/body>/g, '<script src="scripts/bundle.js"></script></body>');
|
||||||
|
|
||||||
const minified = await htmlMinify(updatedHTML, {
|
const minified = await htmlMinify(updatedHTML, {
|
||||||
|
|||||||
15
nginx.conf
15
nginx.conf
@@ -40,14 +40,21 @@ http {
|
|||||||
add_header X-XSS-Protection "1; mode=block" always;
|
add_header X-XSS-Protection "1; mode=block" always;
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
|
||||||
|
# Temporary: Disable caching during development
|
||||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
expires 1w;
|
# expires 1w;
|
||||||
add_header Cache-Control "public, immutable";
|
# add_header Cache-Control "public, immutable";
|
||||||
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
add_header Pragma "no-cache";
|
||||||
|
add_header Expires "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* \.html$ {
|
location ~* \.html$ {
|
||||||
expires 1h;
|
# expires 1h;
|
||||||
add_header Cache-Control "public";
|
# add_header Cache-Control "public";
|
||||||
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
|
add_header Pragma "no-cache";
|
||||||
|
add_header Expires "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
location /health {
|
location /health {
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="color-scheme" content="light dark">
|
<meta name="color-scheme" content="light dark">
|
||||||
<link rel="stylesheet" href="css/pico.green.min.css">
|
<link rel="stylesheet" href="css/pico.jade.min.css">
|
||||||
<link rel="stylesheet" href="css/pico.colors.min.css">
|
|
||||||
<link rel="stylesheet" href="site-styles/style.css">
|
<link rel="stylesheet" href="site-styles/style.css">
|
||||||
<title>Keyboard Vagabond</title>
|
<title>Keyboard Vagabond</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user