javascript - Allow global transforms with grunt browserify -


i've added jquery script tag in html file , have added package.json working browserify-shim follows:

  "browserify": {     "transform": [       "browserify-shim"     ]   },   "browserify-shim": {     "jquery": "global:jquery"   }, 

i'm able expose in main script file simple require('jquery') call.

the problem i'm using jquery plugins internally require('jquery') , since browserify transforms don't apply dependency of dependencies, it's causing browserify complain bundling since cannot find jquery.

now know can solve applying global-transforms cannot find way easily.

browserify docs cannot apply global-transforms in package file following don't work, (which thought would):

  "browserify": {     "global-transform": [       "browserify-shim"     ]   },    "browserify": {     "transform": [       "browserify-shim"     ],     "global": true   }, 

i tried adding option gruntfile.js follows, doesn't work:

browserify: {         options: {             global: true         },         dist: {             files: {                 'js/bundle.js': 'js/script.js'             }         },     }, 

the last option manually add browserify-shim every dependency's package.json, don't want it, since means every time add new plugin, have repeat same process.

any ideas mitigate above problem?

you should able apply global-transforms providing transform hash option:

 "browserify": {    "transform": [      ["browserify-shim", {global: true}]    ]  } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -