zoukankan      html  css  js  c++  java
  • grunt+bower依赖管理

    安装bower(必须安装git)

    npm install bower -g
    

    bower按照插件命令
    初始化配置

    bower init 生成bower.json
    //如果有bower.json 直接输入bower install下载依赖组件,这个和grunt一样。
    bower install jquery --save(save 保存到bower.json)
    
    {
      "name": "grunt_bower",
      "description": "lib bower",
      "main": "index.js",
      "authors": [
        "cjw"
      ],
      "license": "ISC",
      "homepage": "",
      "ignore": [
        "**/.*",
        "node_modules",
        "bower_components",
        "test",
        "tests"
      ],
      "dependencies": {
        "jquery": "^1.11.3",
        "requirejs": "^2.2.0",
        "text": "^2.0.15",
        "underscore": "^1.8.3",
        "backbone": "https://github.com/marionettejs/backbone.wreqr/"
      }
    }
    

    为了把bower按照的插件拷贝到lib下面、
    为了实现这样的功能,我们还需要另一个插件的帮助:

    npm install grunt-bower-task --save-dev
    

    然后打开其文档,按照上面的提示进行配置。首先在 Gruntfile 中合适位置添加:

    grunt.loadNpmTasks('grunt-bower-task');
    

    然后在 grunt.initConfig({...}) 参数中,添加相应的配置项,把bower下载的js库拷贝到 public/js/lib 下:

    {
      "bower": {   
       "install": { 
            "options": {
                    "targetDir": "./public/js/lib",
                    "layout": "byComponent",
                    "install": true,
                    "verbose": false,
                    "cleanTargetDir": false
                  }
              }
          }
    }
    

    然后直接输入 grunt bower
    也可以直接写到watch里面

  • 相关阅读:
    Ubuntu中pip的疑难杂症
    Python 分类方法记录
    Python 绘制热图
    脚本学习
    Ubuntu 基础使用教程
    机器学习各种相似性度量及Python实现
    Ubuntu 16.04安装R及Rstudio
    机器学习和数据挖掘领域大牛
    vux+vue-cli3.0坑
    函数的抖动以及节流
  • 原文地址:https://www.cnblogs.com/caijw/p/5433379.html
Copyright © 2011-2022 走看看