“样式" package.json中的字段 [英] "style" field in package.json

查看:206
本文介绍了“样式" package.json中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 Bootstrap

I noticed that Bootstrap and Normalize.css both have a "style" field in their package.json.

为什么会有这个?如果我不得不猜测,那就是允许用户像require('bootstrap')一样轻松地导入已定义的样式表,但这似乎并非如此.

Why do they have this? If I had to guess, it's to allow users to import the defined stylesheet as easily as doing require('bootstrap'), but that doesn't seem to be the case.

推荐答案

来自Techwraith的拉动请求引导:

From Techwraith's pull request that added it to Bootstrap:

npm中的许多模块开始在以下位置公开其css入口文件 他们的package.json文件.这允许使用 npm-css 之类的工具, rework-npm npm-less 从 node_modules目录. [...]

Many modules in npm are starting to expose their css entry files in their package.json files. This allows tools like npm-css, rework-npm, and npm-less to import bootstrap from the node_modules directory. [...]

实际上并没有写在任何地方,而是在这些模块的代码中 现在.我们希望在某个时候使它标准化,但是 我们已经分别达成了这个约定,所以我倾向于 去吧. [...]

It's actually not written anywhere but in the code for these modules right now. We're hoping to get this standardized at some point, but we've all reached this convention separately, so I'm inclined to just go with it. [...]

如果您想了解这种CSS开发风格,我写了一篇 事情:

If you want to read about this style of css development, I wrote a thing:

http://techwraith.com/your-css-needs-a-dependency- graph-too/

其他工具也提供支持,例如browserify插件 parcelify :

There's also support in other tools, such as the browserify plugin parcelify:

将CSS添加到浏览器使用的npm模块中.

Add css to your npm modules consumed with browserify.

  • 只需将样式键添加到package.json以指定程序包的css文件. [...]

Parcelify将串联所有模块中的所有css文件 main.js取决于-在这种情况下只是myModule.css-按顺序 js依赖关系图的示例,然后将输出写入bundle.css.

Parcelify will concatenate all the css files in the modules on which main.js depends -- in this case just myModule.css -- in the order of the js dependency graph, and write the output to bundle.css.

这篇关于“样式" package.json中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆