Browserify and bower. Canonical approach

前端 未结 2 1928
离开以前
离开以前 2021-01-30 09:22

The way I\'m using packages that not available out of the box in npm, right now is like that:

package.json has:

 \"napa\": {
     \"angular\": \"angular         


        
2条回答
  •  野性不改
    2021-01-30 09:41

    You can use browserify-shim and configure the bower-installed modules in your package.json like this:

    "browser": {
      "angular": "./bower_components/angular/angular.js",
      "angular-resource": "./bower_components/angular-resource/angular-resource.js"
    },
    "browserify-shim": {
      "angular": {
        "exports": "angular"
      },
      "angular-resource": {
        "depends": ["./bower_components/angular/angular.js:angular"]
      }
    },
    

    Then your code can require them by their short name as if there were regular npm modules.

    Here is the spec for the "browser" package.json property.

提交回复
热议问题