diff --git a/plugins/extract-css.js b/plugins/extract-css.js index e3331e9..d264bfd 100644 --- a/plugins/extract-css.js +++ b/plugins/extract-css.js @@ -1,4 +1,5 @@ var fs = require('fs') +var path = require('path') var compiler = require('../lib/compiler') module.exports = function (b, opts) { @@ -8,17 +9,23 @@ module.exports = function (b, opts) { var styles = Object.create(null) var outPath = opts.out || opts.o || 'bundle.css' + var allowEmpty = opts.allowEmpty || opts.empty || false b.on('bundle', function (bs) { bs.on('end', function () { - var css = Object.keys(styles) - .map(function (file) { return styles[file] }) - .join('\n') - if (typeof outPath === 'object' && outPath.write) { - outPath.write(css) - outPath.end() - } else if (typeof outPath === 'string') { - fs.writeFile(outPath, css, function () {}) + if (allowEmpty || (!allowEmpty && Object.keys(styles)[0] !== undefined)) { + var css = Object.keys(styles) + .map(function (file) { return styles[file] }) + .join('\n') + if (typeof outPath === 'object' && outPath.write) { + outPath.write(css) + outPath.end() + } else if (typeof outPath === 'string') { + if (!fs.existsSync(path.dirname(outPath))) { + fs.mkdirSync(path.dirname(outPath)) + } + fs.writeFile(outPath, css, function () {}) + } } }) }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy