问题描述
我注意到 Bootstrap 和都在package.json中有一个样式"字段.
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:
实际上并没有写在任何地方,而是在这些模块的代码中 现在.我们希望在某个时候使它标准化,但是 我们已经分别达成了这个约定,所以我倾向于 去吧. [...]
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:
- 只需将样式键添加到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中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!