简体   繁体   English

通过Browserify进行角度

[英]Angular via Browserify

I just want to do the following using browserify: 我只想使用browserify进行以下操作:

var angular = require('angular');
angular.etc ...

The Angular page on npmjs.org gives an alternative using exposify , but I would like to do it using the browserify way, I mean: I want to have a unique bundle, without having to include additional scripts, just as browserify does (basically, without globals). npmjs.orgAngular页面提供了使用exposify的替代方法,但我想使用browserify的方式来实现它,我的意思是:我想要一个唯一的包,而不必像browserify那样包含其他脚本(基本上,没有全局变量)。

Is there anything I can do to achieve this? 我能做些什么来实现这一目标? Is there any transform that I couldnt found or any workaround to make Angular work as a CommonJS module without exposing globals in other sources? 有没有我找不到的任何转换或任何变通方法,可以使Angular用作CommonJS模块而不暴露其他资源中的全局变量?

You can user browserify-shim inside package.json 您可以在package.json中使用browserify-shim

"browser": {
    "angular": "./node_modules/angular/angular.min.js"
  },
  "browserify-shim": {
    "angular": {
      "exports": "angular"
    },
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM