前言
PostCSS is a software development tool that uses JavaScript-based plugins to automate routine CSS operations.(维基百科)
下载依赖
1
| npm install -D postcss postcss-cli
|
转换CSS文件
-o dist/style.css:用于指定单个文件的输出路径
1
| postcss src/style.css -o dist/style.css
|
预设环境
预设开发环境
下载依赖
1
| npm install -D postcss postcss-preset-env
|
修改配置文件
postcss.config.js1 2 3 4 5 6 7
| module.exports = { plugins: [ [ "postcss-preset-env" ] ] }
|
插件
自动添加浏览器前缀
下载依赖
1
| npm install -D postcss autoprefixer
|
修改配置文件
postcss.config.js1 2 3 4 5
| module.exports = { plugins: [ "autoprefixer" ] }
|
完成