Skip to content
Permalink
Browse files

Added base for sass-watcher and twig

  • Loading branch information...
peter-tell committed Jul 19, 2019
1 parent f72264b commit 801adec38d5b61100c665c846c312e15ff02ded3
Showing with 366 additions and 424 deletions.
  1. +44 −0 build-tools/sass-watcher.config.js
  2. +13 −1 build-tools/sync.js
  3. +303 −420 package-lock.json
  4. +6 −3 package.json
@@ -0,0 +1,44 @@
const sass = require('node-sass');
const fs = require('fs');
const chalk = require('chalk');
const automationRoot = './public/automation';

// Filename argument passed via CLI
const args = process.argv.slice(2);
const filepath = args[0];

replaceFile(filepath);

function replaceFile(filepath)
{
// Find the File Name
let filearray = filepath.split('/');
let filename = filearray[filearray.length - 1].replace('.scss', '.css');
sass.render(
{
file: filepath,
outputStyle: 'compressed',
includePaths: ['utils/styles/settings', 'utils/styles/tools']
},
function(error, result){
if (error) {
console.log(chalk.hex('#f57b7b').bold(`SASS Compile Error:`), chalk.white(`${ error.message } at line`), chalk.yellow.bold(error.line), chalk.hex('#ffffff').bold(error.file));
}else{

// Current CSS Directory
fs.readdirSync(automationRoot).forEach(file => {
if (file.indexOf('styles-') !== -1) {
let rewriteFile = automationRoot + '/' + file + '/' + filename;
fs.writeFile(rewriteFile, result.css.toString(), function (err) {
if(err){
success = false;
};
});
}
})
}
}
);

}

@@ -12,9 +12,21 @@ browserSync.init({
proxy: process.env.DEV_URL
});

browserSync.watch("./public/automation/**/*.css", (event, file)=>{
if (event === 'change')
{
browserSync.reload([file]);
}
});
browserSync.watch("./templates/**/*.twig", (event, file)=>{
if (event === 'change')
{
browserSync.reload();
}
});
browserSync.watch("./templates", (event, file)=>{
browserSync.reload;
});
});
browserSync.watch("./public/assets", (event, file)=>{
browserSync.reload;
});

0 comments on commit 801adec

Please sign in to comment.
You can’t perform that action at this time.