Skip to content

Commit

Permalink
Build SASS compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
ezequiel-fr committed Jun 20, 2023
1 parent a7cc5f3 commit 210486b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
19 changes: 8 additions & 11 deletions src/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Configuration } from 'webpack';
import { ErrorSASS, ResultSASS } from './utils/compiler';

import {
existsSync,
Expand All @@ -15,7 +14,7 @@ import { basename, join, resolve as path } from 'node:path';

import { JSDOM } from 'jsdom';

import { compileSASS, compileTS } from './utils/compiler';
import { compileSassFile, compileTS } from './utils/compiler';
import { clearAndLog } from './utils/log';
import config, { Modes } from './config/webpack';

Expand Down Expand Up @@ -98,15 +97,13 @@ writeFileSync(resolve("index.html"), minify(dom.serialize(), {
writeFileSync(resolve(".env"), readFileSync(resolve("../.env")));

// Compile SASS files
compileSASS(
dir.filter(e => e.endsWith('.scss')).map(e => join(path(process.cwd(), "public"), e))
).forEach(e => {
if (Object.prototype.hasOwnProperty.call(e, "error"))
console.error((e as ErrorSASS).error);
else writeFileSync(
resolve("assets", basename((e as ResultSASS).file, "scss") + "css"),
(e as ResultSASS).css,
);
const sassFiles = dir.filter(e => e.endsWith(".scss")).map(e => (
join(path(process.cwd(), "public"), e))
);

sassFiles.forEach(async cssFile => {
const css = await compileSassFile(cssFile, true);
writeFileSync(resolve("assets", basename(cssFile, "scss") + "css"), css);
});

// Build ended
Expand Down
1 change: 0 additions & 1 deletion src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { watch, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

import { compile } from 'sass';
import { WebSocketServer } from 'ws';

import { compileAll, compileSassFile } from './utils/compiler';
Expand Down

0 comments on commit 210486b

Please sign in to comment.