示例#1
0
文件: css.js 项目: xidui/NodeBB
		}, function (err, lessOutput) {
			if (err) {
				winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
				if (typeof callback === 'function') {
					callback(err);
				}
				return;
			}

			postcss([ autoprefixer, clean() ]).process(lessOutput.css).then(function (result) {
				result.warnings().forEach(function (warn) {
					winston.verbose(warn.toString());
				});
				Meta.css[destination] = result.css;

				// Save the compiled CSS in public/ so things like nginx can serve it
				if (nconf.get('isPrimary') === 'true' && (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false)) {
					return Meta.css.commitToFile(destination, function () {
						if (typeof callback === 'function') {
							callback(null, result.css);
						}
					});
				}

				if (typeof callback === 'function') {
					callback(null, result.css);
				}
			});

		});
示例#2
0
            postcss: function() {
                var a = postcssClean(config.style.options.min),
                    b = autoprefixer(config.style.autoprefixer),
                    //处理import css
                    c = postcssImport();

                return !config.dev ? [c, a, b] : [c, b];
            },
示例#3
0
    data && data.forEach(function(value) {
        //获取路径数组
        var arys = value.source;

        //文件名以key命名
        stream = gulp.src(arys)
            .pipe(concat(value.name, {
                newLine: value.newline === undefined ? value.newline : options.newline
            }))

        //替换变量
        stream = modules.replace(stream, config.replace);

        //处理不同文件
        if (value.type == 'js') {

            !config.dev && (stream = stream.pipe(uglify(config.javascript.options.min)));

        } else if (value.type == 'css') {
            processors = [];

            //如果非开发环境,则压缩CSS
            !config.dev && (processors.push(postcssClean(config.style.options.min)));

            stream = stream.pipe(postcss(processors));

        } else if (value.type == config.style.options.suffix) {

            stream = stream.pipe(config.style.options.process());

            processors = [
                postcssImport(),
                autoprefixer(config.style.autoprefixer)
            ];

            //如果非开发环境,则压缩CSS
            !config.dev && (processors.push(postcssClean(config.style.options.min)))

            stream = stream.pipe(postcss(processors));
        }

        //输出到指定目录
        stream = stream.pipe(gulp.dest(util.decideRunFunction(value.output, config)));
    });
示例#4
0
gulp.task('copycss', function() {
    var source = path.join(config.src, '/**/*.css'),
        stream = gulp.src(source),
        processors = [];

    //如果非开发环境,则压缩CSS
    !config.dev && (processors.push(postcssClean(config.style.options.min)));

    stream = stream.pipe(postcss(processors));

    return stream.pipe(gulp.dest(config.staticPath));
});
示例#5
0
	}, function (err, lessOutput) {
		if (err) {
			return callback(err);
		}

		postcss(data.minify ? [
			autoprefixer,
			clean({
				processImportFrom: ['local'],
			}),
		] : [autoprefixer]).process(lessOutput.css).then(function (result) {
			process.nextTick(callback, null, { code: result.css });
		}, function (err) {
			process.nextTick(callback, err);
		});
	});
示例#6
0
文件: engine.js 项目: whxaxes/blog
 // parse scss
 async parseScss(code, fileUrl) {
   return await postcss([
     autoprefixer({
       browsers: [ 'iOS >= 7', 'Android >= 4.0' ],
     }),
     precss(),
     autoMath(),
     ...this.isLocal ? [] : [ clean() ],
   ])
     .process(code, { from: fileUrl })
     .then(({ content }) => content)
     .catch(e => {
       this.logger.error(e);
       return '';
     });
 }
示例#7
0
文件: css.js 项目: Mtechnik/NodeBB
		}, function (err, lessOutput) {
			if (err) {
				winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
				return callback(err);
			}

			postcss(global.env === 'development' ? [ autoprefixer ] : [ autoprefixer, clean() ]).process(lessOutput.css).then(function (result) {
				result.warnings().forEach(function (warn) {
					winston.verbose(warn.toString());
				});

				return Meta.css.commitToFile(target, result.css, function () {
					callback(null, result.css);
				});
			});
		});
示例#8
0
文件: qycss.js 项目: lymail/postcss
 fs.readFile(path.dirname(pat) + path.sep + file, (err, css) => {
     postcss([
             atImport(),
             baseCon.postcssFun.unitConversion,
             sprites(spritesFun(imgPat)),
             precss,
             autoprefixer,
             postcssClean()
         ])
         .process(css, {
             from: path.dirname(pat) + path.sep + file,
             to: cssName
         })
         .then(result => {
             console.log(cssName.green);
             fs.writeFile(cssName, result.css);
         })
         .catch((err) => {
             console.log(err);
         })
 })
示例#9
0
/**
 * Write minified version of the file
 * @param {object} [obj] - obj
 * @param {string} obj.filename -
 * @param {string} obj.styledocPath -
 * @param {string} obj.compiledCss -
 * @param {string} obj.outputFolder -
 * @return {Promise} A Promise
 */
async function generateMinifiedAsync({ filename, styledocPath, compiledCss, outputFolder }) {
	// write in parallel minified version
	logger.log(`minify stylesheet: filename:${filename}`);
	// minify via clean-css
	const minPlugins = [];
	// generate css documentation??
	if (styledocPath) {
		const pathDoc = `${trimEnd(styledocPath, '/')}_${filename}`;
		debug(`[CSS] Generate documentation for ${filename} pathDoc: ${pathDoc}`);
		minPlugins.push(mdcss({ destination: pathDoc, assets: [] })); // assets: The list of files or directories to copy into the style guide directory.
	}
	// add css-clean plugin for minify
	minPlugins.push(postcssClean());
	const processedMinCssObject = await postcss(minPlugins).process(compiledCss.css);

	// compute the hash(md5) of the file
	const filehash = crypto.createHash('md5').update(processedMinCssObject.css, 'utf8').digest('hex');
	await fs.writeAsync(`${outputFolder}${filename}.${filehash}.css`, processedMinCssObject.css);
	// generate map file for min ???
	if (processedMinCssObject.map) await fs.writeAsync(`${outputFolder}${filehash}.css.map`, processedMinCssObject.map);
	return { filename: `${filename}.css`, filehash: `${filehash}.css` };
}
示例#10
0
gulp.task('css', function() {
    var matchSuffix = '/**/*.' + config.style.options.suffix,
        source = [path.join(config.src, matchSuffix), '!' + path.join(config.src, config.component, matchSuffix), '!' + path.join(config.src, config.lib, matchSuffix)],
        stream = gulp.src(source, {
            base: config.src
        });

    stream = stream.pipe(config.style.options.process());

    var processors = [
        postcssImport(),
        autoprefixer(config.style.autoprefixer)
    ];

    //如果非开发环境,则压缩CSS
    !config.dev && (processors.push(postcssClean(config.style.options.min)));

    stream = stream.pipe(postcss(processors));

    //替换变量
    stream = modules.replace(stream, config.replace);

    return stream.pipe(gulp.dest(path.join(config.staticPath)));
});
示例#11
0
 plugins: () => [
   cssClean({
     inline: ['none']
   }),
   autoprefixer()
 ]
示例#12
0
 postcss: function() {
   return [autoprefixer, clean({processImport: false})];
 }