Skip to content

Commit

Permalink
updates sass
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Apr 15, 2023
1 parent e2bcf92 commit 88c31e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
26 changes: 17 additions & 9 deletions bin/sassTocss.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ const convertToCSS = (fullPath, targetPath) => {
});
};

fs.readdirSync(dir).forEach(file => {
const fullPath = path.join(dir, file);
const targetPath = fullPath.replace('app/', 'public/');
const targetCSS = targetPath.replace('.scss', '.css');
const readCSSDir = () => {
fs.readdirSync(dir).forEach(file => {
const fullPath = path.join(dir, file);
const targetPath = fullPath.replace('app/', 'public/');
const targetCSS = targetPath.replace('.scss', '.css');

// to exclude modules folder
if (!fs.lstatSync(fullPath).isDirectory()) {
convertToCSS(fullPath, targetCSS);
}
});
}

readCSSDir();

module.exports = { readCSSDir }


// to exclude modules folder
if (!fs.lstatSync(fullPath).isDirectory()) {
convertToCSS(fullPath, targetCSS);
}
});
22 changes: 2 additions & 20 deletions bin/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const partials = require('./partials.js');
const utils = require('./utils.js');
const path = require('path');
const config = require('./config.js');
const sass = require('sass');
const sass = require('./sassToCss.js');
const precompileHbsTemplates = require('./hbs.js');

/* watching js files for bundling */
Expand All @@ -33,28 +33,10 @@ const watcher = chokidar.watch('.', {
cwd: 'app'
});

const watchCSS = () => {
sass.render({
file: './app/resources/css/styles.scss',
includePaths: ['./app/resources/css/modules/']
}, function(err, result) {
if(!err) {
// No errors during the compilation, write this result on the disk
fs.writeFile('public/resources/css/styles.css', result.css, function(err){
if(!err){
//file written on disk
}
});
} else {
console.error(err);
}
});
};

/* copies assets and resources to public folder */
const copyFile = (filepath) => {
if (filepath.indexOf('resources/css') >= 0) {
watchCSS();
sass.readCSSDir();
} else if (filepath.indexOf('resources/hbs') >= 0) {
precompileHbsTemplates();
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "1.0.3",
"version": "1.0.4",
"description": "A frontend build for HTML Websites",
"repository": {
"type": "git",
Expand Down

0 comments on commit 88c31e0

Please sign in to comment.