Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1] PostCSS 入口文件 #1

Open
egoist opened this issue Jan 7, 2016 · 0 comments
Open

[1] PostCSS 入口文件 #1

egoist opened this issue Jan 7, 2016 · 0 comments

Comments

@egoist
Copy link
Owner

egoist commented Jan 7, 2016

Since postcss/postcss@106cfa2


今天开讲 PostCSS,那就得从 ./index.js 说起,万事开头简单,./index.js 就两行:

require('babel-core/register')({ extensions: ['.es6'] });
module.exports = require('./lib/postcss');

什么意思呢?

第一行引入了 babel 的注册器,这样之后 require 的内容都将被 babel 转换为 es5 的格式,而 extensions 则指定让 babel 只转换 .es6 后缀的文件。

这个 ./index.js 大概只是开发时用的,开发者在发布新版本的时候会把所有 .es6 文件编译成 es5 再发布,这样做的好处是开发时免去了编译这一环节,提高效率。


好了,今天第一讲很简单,下期再见!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant