Initial commit
This commit is contained in:
commit
d3978ee3e4
11 changed files with 1053 additions and 0 deletions
74
compile.js
Normal file
74
compile.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const pug = require("pug");
|
||||
const sass = require("sass");
|
||||
|
||||
// Base directories
|
||||
const srcDir = path.join(__dirname, "src");
|
||||
const viewsDir = path.join(srcDir, "views");
|
||||
const distDir = path.join(__dirname, "dist");
|
||||
|
||||
// Ensure dist directory exists
|
||||
if (!fs.existsSync(distDir)) {
|
||||
fs.mkdirSync(distDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Compile SCSS to CSS and save to dist
|
||||
console.log("Compiling SCSS to CSS...");
|
||||
try {
|
||||
const result = sass.compile(path.join(srcDir, "styles.scss"), {
|
||||
style: "compressed",
|
||||
});
|
||||
fs.writeFileSync(path.join(distDir, "styles.css"), result.css);
|
||||
console.log("Successfully compiled SCSS to CSS");
|
||||
} catch (error) {
|
||||
console.error("Error compiling SCSS:", error);
|
||||
}
|
||||
|
||||
// Define pages with their titles and taglines
|
||||
const pages = [
|
||||
{
|
||||
name: "index",
|
||||
title: "IRC Community",
|
||||
tagline: "Modern IRC community",
|
||||
},
|
||||
{
|
||||
name: "login",
|
||||
title: "Login",
|
||||
tagline: "Account Login",
|
||||
},
|
||||
{
|
||||
name: "register",
|
||||
title: "Registration",
|
||||
tagline: "Account Registration",
|
||||
},
|
||||
{
|
||||
name: "channels",
|
||||
title: "Channels",
|
||||
tagline: "IRC Channels",
|
||||
},
|
||||
];
|
||||
|
||||
// Compile each page
|
||||
console.log("Compiling Pug templates to HTML...");
|
||||
|
||||
for (const page of pages) {
|
||||
const pugFilePath = path.join(viewsDir, `${page.name}.pug`);
|
||||
const htmlOutputPath = path.join(distDir, `${page.name}.html`);
|
||||
|
||||
try {
|
||||
// Compile the template
|
||||
const html = pug.renderFile(pugFilePath, {
|
||||
title: page.title,
|
||||
tagline: page.tagline,
|
||||
});
|
||||
|
||||
// Write the compiled HTML to the output file
|
||||
fs.writeFileSync(htmlOutputPath, html);
|
||||
console.log(`Successfully compiled ${page.name}.pug to ${page.name}.html`);
|
||||
} catch (error) {
|
||||
console.error(`Error compiling ${page.name}.pug:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("All files compiled successfully!");
|
Loading…
Add table
Add a link
Reference in a new issue