具有以下配置的Require.js优化器r.js只是将文件复制到appDir / distr而没有任何优化(连接,压缩,uglify):
({
appDir: "../",
baseUrl: "./",
dir: "../distr",
optimizeCss: "standard",
modules: [
{
name: "js/main"
}
],
paths: {
jquery: 'js/libs/jquery/jquery-2.0.3.min',
jquery_cookie: 'js/libs/jquery/jquery.cookie-1.3.1',
underscore: 'js/libs/underscore/underscore-1.5.1',
backbone: 'js/libs/backbone/backbone-1.0.0',
marionette: 'js/libs/backbone/backbone.marionette-1.0.4',
text: 'js/libs/require/text-2.0.10',
Handlebars: 'js/libs/handlebars/handlebars-1.0.0',
handlebars_helpers: 'js/libs/handlebars/helpers',
hbs: 'js/libs/require/hbs-0.4.0',
'hbs/underscore': 'js/libs/require/hbs/underscore',
'hbs/i18nprecompile': 'js/libs/require/hbs/i18nprecompile',
'hbs/json2': 'js/libs/require/hbs/json2',
bootstrap: 'js/libs/bootstrap/bootstrap.min',
jquery_typing: 'js/libs/jquery/jquery-typing-0.2.0',
'template/helpers/ifCond': 'js/libs/handlebars/helpers',
'template/helpers/ifNull': 'js/libs/handlebars/helpers'
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
marionette: {
deps: ['backbone'],
exports: 'Marionette'
},
Handlebars: {
exports: 'Handlebars'
},
handlebars_helpers: {
exports: 'Handlebars'
},
bootstrap: {
deps: ['jquery'],
exports: 'Bootstrap'
}
},
hbs : {
templateExtension : 'html',
disableI18n : true
}
})
我使用以下命令运行优化:
node ./r.js -o ./js/build.js
它将所有文件从appDir复制到appDir / distr并跟踪:
# node ./r.js -o ./js/build.js
Optimizing (standard) CSS file: /home/www/myproject.local/distr/css/bootstrap.min.css
Optimizing (standard) CSS file: /home/www/myproject.local/distr/css/styles.css
Tracing dependencies for: js/main
#
为什么优化js文件不起作用?
答案 0 :(得分:0)
车把助手应该依赖于车把:
handlebars_helpers: {
exports: 'Handlebars'
deps: ['Handelbar'],
},