Bower - How to install jquery.js only and not the whole package?

拈花ヽ惹草 提交于 2019-12-18 10:12:19

问题


Using bower install jquery command what I get in jquery folder are dist folder with jquery.js and jquery.min.js, src folder with the whole bunch of js files that make up jquery, I suppose, bower.json and licence files. How could I install jquery.js or jquery.min.js only?


回答1:


You can use bower-installer and an extra "install" section in your bower.json file like:

{
    "name": "test",
    "version": "0.0.0",
    "dependencies": {
        "jquery": "1.11.1",
        "normalize-css": "latest"
    },
    "install" : {
        "path"  : {
            "js": "_js/",
            "css": "_css/"
        }
    }
}

With that "install" section you can specify the install folder.
It than automatically creates the folders - if they're not existing - and installs just the required files like jquery.js or normalize.css to the specified "css" or "js" folder.




回答2:


From the jQuery download page:

The jQuery Bower package contains additional files besides the default distribution. In most cases you can ignore these files, however if you wish to download the default release on it's own you can use Bower to install jQuery from one of the above urls instead of the registered package. For example, if you wish to install just the compressed jQuery 2.1.0, you can install just that file with the following command:

bower install http://code.jquery.com/jquery-2.1.0.min.js




回答3:


You can also use this parameter:

"ignore": [
        "source",
        "spec",
        ".bowerrc",
        ".gitignore",
        ".jshintignore",
        ".jshintrc",
        "bower.json",
        "gruntfile.js",
        "package.json",
        "README.md"
    ],

This will ignore the unecessary files to work when you download files.



来源:https://stackoverflow.com/questions/22464049/bower-how-to-install-jquery-js-only-and-not-the-whole-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!