nunta/scripts/render-scss.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-04-07 00:19:58 +02:00
'use strict';
const autoprefixer = require('autoprefixer')
const fs = require('fs');
const packageJSON = require('../package.json');
const upath = require('upath');
2020-04-07 00:19:58 +02:00
const postcss = require('postcss')
const sass = require('sass');
const sh = require('shelljs');
const stylesPath = '../src/scss/styles.scss';
const destPath = upath.resolve(upath.dirname(__filename), '../dist/css/styles.css');
2020-04-07 00:19:58 +02:00
module.exports = function renderSCSS() {
const results = sass.renderSync({
data: entryPoint,
includePaths: [
upath.resolve(upath.dirname(__filename), '../node_modules')
2020-04-07 00:19:58 +02:00
],
});
const destPathDirname = upath.dirname(destPath);
2020-04-07 00:19:58 +02:00
if (!sh.test('-e', destPathDirname)) {
sh.mkdir('-p', destPathDirname);
}
postcss([ autoprefixer ]).process(results.css, {from: 'styles.css', to: 'styles.css'}).then(result => {
result.warnings().forEach(warn => {
console.warn(warn.toString())
})
fs.writeFileSync(destPath, result.css.toString());
})
};
const entryPoint = `/*!
* Start Bootstrap - ${packageJSON.title} v${packageJSON.version} (${packageJSON.homepage})
* Copyright 2013-${new Date().getFullYear()} ${packageJSON.author}
2020-06-17 23:51:44 +02:00
* Licensed under ${packageJSON.license} (https://github.com/StartBootstrap/${packageJSON.name}/blob/master/LICENSE)
2020-04-07 00:19:58 +02:00
*/
@import "${stylesPath}"
`