You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Dependenciesvarfs=require('fs');varpostcss=require('postcss');varcncss=require('postcss-chinese-stylesheets');// CSS to be processedvarcss=fs.readFileSync('input.css','utf8');// Process our chinese stylesheets css using postcss-chinese-stylesheetsvaroutput=postcss().use(cncss()).process(css).cssconsole.log('\n===>Output CSS:\n',output);
项目地址
项目地址:https://github.com/zhouwenbin/postcss-chinese-stylesheets
所有属性:https://github.com/zhouwenbin/chinese-css-properties
所有值:https://github.com/zhouwenbin/chinese-css-values
安装
在命令行输入
配置
postcss
新建一个
postcss.js
文件,代码如下在命令行输入
node postcss.js
执行grunt
在根目录新建
gruntfile.js
,代码如下在命令行输入
grunt postcss
gulp
在根目录新建gulpfile.js,代码如下
在命令行输入
gulp
实现方法
这东西只是好玩,前前后后只花了几个小时。依托postcss,我们很容易自定义样式替换规则,随便找个postcss插件,修改
index.js
文件prop
就是属性,value
就是值。接着就可以这么写样式了编译后变成
只要规则足够多,就可以用中文写样式了,有点蛋疼就是了。但是一些颜色英文记不住,可以用中文来代替。
提交代码
如果有翻译的不好不对的,或者有漏掉的,欢迎提交pull request。
有一点需要注意的是,如果名字包含相同的中文字,字少的放后面,不然会出错。修改完先跑下测试用例。
The text was updated successfully, but these errors were encountered: