How to use the autoprefixer.defaults function in autoprefixer

To help you get started, we’ve selected a few autoprefixer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github john-yuan / loader.archive.js / dev-tools / builder / lib / compressCss.js View on Github external
cssText = mixin + '\n' + cssText;

    // 编译 LESS
    less.render(cssText, function (err, res) {
        if (err) {
            printUtils.error(`编译 LESS 失败! ${name}`);
            throw err;
        } else {
            cssText = res.css;
        }
    });

    // 添加 CSS 浏览器前缀
    try {
        let prefixer = postcss([autoprefixer({
            browsers: runtime.config.autoprefixerBrowsers || autoprefixer.defaults
        })]);
        cssText = prefixer.process(cssText).css;
    } catch(e) {
        printUtils.error(`添加 CSS 浏览器前缀失败! ${name}`);
        throw e;
    }

    // 压缩 CSS 文件
    try {
        let cleanCss = new CleanCSS();
        cssText = cleanCss.minify(cssText).styles;
    } catch(e) {
        printUtils.error(`压缩样式表失败! ${name}`);
        throw e;
    }
github sindresorhus / atom-autoprefixer / index.js View on Github external
} catch (error) {
		if (error.name === 'CssSyntaxError') {
			error.message += error.showSourceCode();
		}

		console.error(error);
		atom.notifications.addError('Autoprefixer', {detail: error.message});
	}
}

export const config = {
	browsers: {
		title: 'Supported Browsers',
		description: 'Using the [following syntax](https://github.com/ai/browserslist#queries).',
		type: 'array',
		default: autoprefixer.defaults,
		items: {
			type: 'string'
		}
	},
	cascade: {
		title: 'Cascade Prefixes',
		type: 'boolean',
		default: true
	},
	remove: {
		title: 'Remove Unneeded Prefixes',
		type: 'boolean',
		default: true
	},
	runOnSave: {
		title: 'Run on Save',
github john-yuan / loader.archive.js / dev-tools / builder / lib / compressHtml.js View on Github external
styles.forEach(function (style) {
        if (style.hasAttribute('@remove')) {
            style.parentNode.removeChild(style);
        } else {
            let code = (style.innerHTML || '').trim();
            if (code) {
                try {
                    let prefixer = postcss([autoprefixer({
                        browsers: runtime.config.autoprefixerBrowsers || autoprefixer.defaults
                    })]);
                    code = prefixer.process(code).css;
                } catch(e) {
                    printUtils.error(`添加 CSS 浏览器前缀失败!\n${code}`);
                    throw e;
                }
                try {
                    let cleanCss = new CleanCSS();
                    code = cleanCss.minify(code).styles;
                } catch(e) {
                    printUtils.error(`压缩 CSS 失败!\n${code}`);
                    throw e;
                }
                style.innerHTML = code;
            }
        }