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 文件的优化不起作用?