以下设置可让jQuery
插件mixitup
完美运行。
"browser": {
"mixitup": "./app/bower_components/mixitup/src/jquery.mixitup.js",
"jquerymustache": "./app/bower_components/jquery-Mustache/src/jquery.mustache.js"
},
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"mixitup": {
"exports": "mixitup",
"depends": [
"jquery:jQuery"
]
},
"jquerymustache": {
"exports": "Jquerymustache",
"depends": [
"jquery:jQuery",
"mustache:mustache"
]
}
},
但是,当我尝试将相同的约定应用于jquery-Mustache
时,我无法获取模板:
"browser": {
"jquerymustache": "./app/bower_components/jquery-Mustache/src/jquery.mustache.js"
}
和
"jquerymustache": {
"exports": "Jquerymustache",
"depends": [
"jquery:jQuery",
"mustache:mustache"
]
}
我没有从终端收到错误,(这会证明package.json
设置是犹太洁食)但我确实从控制台收到此错误:
http://embed.plnkr.co/vZI7aC/preview
指出这一点:
这是我的app.js文件,觉得这是最相关的信息:
var $ = jQuery = require('jquery');
var mixitup = require('mixitup');
var Jquerymustache = require('jquerymustache');
var mustache = require('mustache');
获取模板的功能。
function templateLoader(e) {
var doc = document,
event = EventUtility.getEvent(e),
target = EventUtility.getTarget(event);
$.Mustache.options.warnOnMissingTemplates = true;
$.Mustache.load('templates/index.html')
.fail(function() {
$('#overlay').append('Failed to load templates from <code>templates.htm</code>');
})
.done(function() {
var output = $('#overlay');
$('body').mustache('templateID');
});
}
用于良好测量的文件路径,以证明函数中的路径是正确的: