Including JQuery Mobile in a Node JS project with Browserify

后端 未结 4 606
面向向阳花
面向向阳花 2021-01-12 14:59

I\'m writing a Node JS application where I need both jQuery UI and jQuery Mobile. I\'m using Browserify to pack the modules in a single js file.

I have the following

4条回答
  •  -上瘾入骨i
    2021-01-12 15:30

    Here is a simple runnable demo using browserify-shim and jquery + jquery mobile: https://gist.github.com/mchelen/a8c5649da6bb50816f7e

    The most important lines are:

    package.json

     "browserify-shim": {
       "jquery": "$",
       "jquery-mobile" : { "exports": "$.mobile", "depends": [ "jquery:$" ] }
     }, 
    

    entry.js

    var $ = require('jquery');
    $.mobile = require('jquery-mobile'); 
    

提交回复
热议问题