2.9.0 • Published 8 years ago

tpack-postcss v2.9.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

tpack-postcss

TPack 插件:使用 PostCSS 优化 CSS。

如果您只需要使用 AutoPrefixer 提供的功能,可以考虑使用 tpack-autoprefixer 插件。

安装

$ npm install tpack-postcss -g

安装常用 PostCSS 插件

$ npm install autoprefixer precss -g

使用

优化 CSS

tpack.src("*.css").pipe(tpack.plugin("tpack-postcss"), {
	processors: [
		require('autoprefixer'), 
		require('precss')
	]
});

源映射(Source Map)

本插件可生成源映射,具体用法见 源映射

配置

tpack.src("*.css").pipe(tpack.plugin("tpack-postcss"), {
	processors: [					// 指定各个 PostCSS 处理器插件。[2]
		require('autoprefixer')({}),// autoprefixer 配置。
		require('precss')({})   	// precss 配置。
	],
	from: "",						// 源文件路径。[1]
	to: "",							// 目标文件路径。[1]
	map: null,						// 是否生成源映射。是否生成源映射。具体见 [map](https://github.com/postcss/postcss/blob/master/docs/source-maps.md)。[1]
	parser: null,					// 自定义 CSS 解析器。如 [SCSS](https://github.com/postcss/postcss-scss)。
	stringifier: null,				// 自定义 CSS 生成器。如 [Midas](https://github.com/ben-eb/midas)。
	syntax: null,					// 同时包含 parser 和 stringifier 的 JSON 对象。
});

1: 插件内部已重设了此配置的默认值。

2: 此配置由插件提供。

另参考 https://github.com/postcss/postcss