当您运行bower init时,主文件(main file)属性有什么用途?我一直在寻找答案,但许多人说它目前没有实际用途。
这是真的吗?Bower的文档也没有解释。
当您运行bower init时,主文件(main file)属性有什么用途?我一直在寻找答案,但许多人说它目前没有实际用途。
这是真的吗?Bower的文档也没有解释。
主文件
推荐类型:字符串或字符串数组
使用你的软件包必需的主要操作文件。虽然Bower不直接使用这些文件,但它们会被列在命令bower list --json和bower list --paths中,以便可以被构建工具使用。
像CoffeeScript之类的预处理器文件应该被编译。不要包括已被最小化的文件。文件名不应该有版本号(不好的做法:package.1.1.0.js;好的做法:package.js)。
我认为这更适用于包管理和构建工具,如Grunt和Brunch。例如,Bootstrap的bower.json看起来像:
{
"name": "bootstrap",
"version": "3.0.3",
"main": [
"./dist/css/bootstrap.css",
"./dist/js/bootstrap.js",
"./dist/fonts/glyphicons-halflings-regular.eot",
"./dist/fonts/glyphicons-halflings-regular.svg",
"./dist/fonts/glyphicons-halflings-regular.ttf",
"./dist/fonts/glyphicons-halflings-regular.woff"
],
"ignore": [
"**/.*",
"_config.yml",
"CNAME",
"composer.json",
"CONTRIBUTING.md",
"docs",
"js/tests"
],
"dependencies": {
"jquery": ">= 1.9.0"
}
}
当我使用Brunch创建时,它会从我的public
文件夹中的bower_components
文件夹中提取这些文件。
main
属性定义的问题,并在Bower Github存储库上的一个公开问题中进行了讨论和辩论。请查看此处以获取当前提议的定义和讨论:https://github.com/bower/bower/issues/935 - BenjaminGolder