2020-11-27 16:01:54 -05:00
|
|
|
|
|
|
|
|
import sass from 'node-sass';
|
|
|
|
|
import paths from '../mconfig.json';
|
|
|
|
|
import fs from 'fs';
|
|
|
|
|
import message from './utils/message.js';
|
|
|
|
|
|
|
|
|
|
export function compileStyles() {
|
2020-12-11 10:41:07 -05:00
|
|
|
console.time('Styles built in');
|
2020-11-27 16:01:54 -05:00
|
|
|
|
|
|
|
|
// Compile main scss
|
|
|
|
|
sass.render({
|
|
|
|
|
file: paths.styles.src + paths.styles.main + '.scss',
|
|
|
|
|
outFile: paths.styles.dest + paths.styles.main + '.css',
|
|
|
|
|
outputStyle: 'compressed',
|
|
|
|
|
sourceMap: true
|
|
|
|
|
}, (error, result) => {
|
2020-12-11 10:41:07 -05:00
|
|
|
|
2020-11-27 16:01:54 -05:00
|
|
|
if(error) {
|
2020-12-11 10:41:07 -05:00
|
|
|
message('Error compiling main.scss', 'error');
|
2020-11-27 16:01:54 -05:00
|
|
|
console.log(error);
|
|
|
|
|
} else {
|
2020-12-11 10:41:07 -05:00
|
|
|
message('Styles built', 'success', 'Styles built in');
|
2020-11-27 16:01:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!error){
|
|
|
|
|
// No errors during the compilation, write this result on the disk
|
|
|
|
|
fs.writeFile(paths.styles.dest + paths.styles.main + '.css', result.css, (err) => {});
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-12-11 10:41:07 -05:00
|
|
|
|
|
|
|
|
console.time('Critical style built in');
|
|
|
|
|
|
2020-11-27 16:01:54 -05:00
|
|
|
// Compile critical scss
|
|
|
|
|
sass.render({
|
|
|
|
|
file: paths.styles.src + paths.styles.critical + '.scss',
|
|
|
|
|
outFile: paths.styles.dest + paths.styles.critical + '.css',
|
|
|
|
|
outputStyle: 'compressed',
|
|
|
|
|
sourceMap: true
|
|
|
|
|
}, (error, result) => {
|
2020-12-11 10:41:07 -05:00
|
|
|
|
2020-11-27 16:01:54 -05:00
|
|
|
if(error) {
|
2020-12-11 10:41:07 -05:00
|
|
|
message('Error compiling critical.scss', 'error');
|
2020-11-27 16:01:54 -05:00
|
|
|
console.log(error);
|
|
|
|
|
} else {
|
2020-12-11 10:41:07 -05:00
|
|
|
message('Critical style built', 'success', 'Critical style built in');
|
2020-11-27 16:01:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!error){
|
|
|
|
|
// No errors during the compilation, write this result on the disk
|
|
|
|
|
fs.writeFile(paths.styles.dest + paths.styles.critical + '.css', result.css, (err) => {});
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-12-11 10:41:07 -05:00
|
|
|
}
|