【发布时间】:2016-03-21 05:20:34
【问题描述】:
我通过r.js -o build.js创建了require.js项目
但是,它给了我控制台上的异常
define('hbs/下划线',[],function() {
这是生成的app.min.js
https://gist.github.com/poc7667/ecf36474b68799ebb29d
有解决问题的办法吗?我使用选项wrap: true 是为了避免与其他脚本冲突,这会给我常见的mismatch 异常
HTML
<script type="text/javascript" src="js/app.min.js" ></script>
build.js
{
name: "app.main.js",
mainConfigFile: 'app.main.js',
out: "./app.min.js",
optimize: 'none',
wrap: true,
include: [ 'app.main' ],
insertRequire: ["app.main"],
}
app.main.js
requirejs.config({
paths: {
jquery: './vendor/js/jquery-2.1.1.min',
underscore: './vendor/js/underscore-min',
backbone: './vendor/js/backbone-min',
json2: './vendor/js/hbs/hbs/json2',
hbs: './vendor/js/hbs/hbs',
handlebars: './vendor/js/handlebars-v4.0.5',
text: './vendor/js/text',
},
hbs: { // optional
helpers: true, // default: true
templateExtension: 'hbs', // default: 'hbs'
partialsUrl: '' // default: ''
},
shim: {
handlebars: {
exports: 'Handlebars'
},
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
'jquery': {
'exports' : '$'
}
},
});
require(["require", "app"],function(Req, App ){
$("#sample_app_comments_plugin").hide();
$('head').append('<link rel="stylesheet" href='+cfg.css_style_link+' type="text/css" />');
return App.initialize();
});
hbs.js
define(['hbs/handlebars', 'hbs/underscore', 'hbs/json2'], function (Handlebars, _, JSON) {
function precompile(string, _unused, options) {
var ast, environment;
....
【问题讨论】:
标签: javascript requirejs r.js