@zohodesk/client_build_tool
Version:
A CLI tool to build web applications and client libraries
37 lines (28 loc) • 981 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.runPostCssForCssFile = runPostCssForCssFile;
var _postcss = _interopRequireDefault(require("postcss"));
var _fs = require("fs");
var _getAllowedPostCssPlugins = require("./getAllowedPostCssPlugins");
var _copyFile = require("../fileUtils/copyFile");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function runPostCssForCssFile({
filename,
outputFile,
options
}) {
const getAllowedPostCssPlugins = (0, _getAllowedPostCssPlugins.postcssPluginGetter)(options);
const allowedPostCssPlugins = getAllowedPostCssPlugins(filename);
if (allowedPostCssPlugins.length === 0) {
return;
}
const css = (0, _fs.readFileSync)(filename).toString();
(0, _postcss.default)(allowedPostCssPlugins).process(css, {
from: filename,
to: outputFile
}).then(result => {
(0, _copyFile.writeFile)(outputFile, result.css);
});
}