0.0.0 • Published 2 years ago
postcss-test-plugin v0.0.0
postcss-test-plugin
PostCSS plugin testdong.
body {
/* Footer will be hidden on iOS Safari because of bottom panel */
height: 100vh;
}
body {
height: 100vh;
}
/* Avoid Chrome to see Safari hack */
@supports (-webkit-touch-callout: none) {
body {
/* The hack for Safari */
height: -webkit-fill-available;
}
}
Usage
Step 1: Install plugin:
npm install --save-dev postcss postcss-test-plugin
Step 2: Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
module.exports = {
plugins: [
+ require('postcss-test-plugin'),
require('autoprefixer')
]
}
编写 postcss 的全过程
- 使用 postcss-plugin-boilerplate 快速创建一个 postcss 项目,默认生成 postcss8 的项目
npx postcss-plugin-boilerplate <directory>
项目结构
index.js
编写插件具体实现index.test.js
测试用例css ast 结构
- AtRule @media 格式的 rule
- Rule css selector
- Declaration 样式 key: value 数据
- postcss 插件的发布
npx clean-publish
参考项目
-postcss-100vh-fix 兼容 Safari 上面的 100vh 的 postcss 插件
0.0.0
2 years ago