Jquery mobile r、 js没有缩小jquery mobile
我有一个使用RequireJS和jquery mobile的项目。我曾尝试运行r.js来编译整个项目,但似乎jquery mobile在编译过程中被忽略了 我意识到CDN是大多数项目的一个选项,这个是内部的,可能没有网络连接,所以在这里它不是一个真正的选项 这是我的主配置文件:Jquery mobile r、 js没有缩小jquery mobile,jquery-mobile,requirejs,Jquery Mobile,Requirejs,我有一个使用RequireJS和jquery mobile的项目。我曾尝试运行r.js来编译整个项目,但似乎jquery mobile在编译过程中被忽略了 我意识到CDN是大多数项目的一个选项,这个是内部的,可能没有网络连接,所以在这里它不是一个真正的选项 这是我的主配置文件: require.config({ baseUrl: "js", paths: { "backbone": "vendor/backbone-amd/backbone", "jquery": "ve
require.config({
baseUrl: "js",
paths: {
"backbone": "vendor/backbone-amd/backbone",
"jquery": "vendor/jquery/jquery",
"jquery-mobile": "vendor/jquery-mobile-compiled/jquery-mobile",
"waypoints": "vendor/jquery-waypoints/waypoints",
"modernizr": "vendor/modernizr/modernizr",
"requirejs": "vendor/requirejs/require",
"underscore": "vendor/underscore-amd/underscore",
"text": "vendor/requirejs-text/text",
"handlebars": "vendor/handlebars.js/handlebars"
},
shim: {
"handlebars": {
exports: "Handlebars"
},
"modernizr": {
exports: "Modernizr"
}
}
});
// Includes File Dependencies
require([ "jquery", "backbone", "router/mobileRouter", "modernizr" ], function ($, Backbone, MobileRouter, Modernizr) {
$(document).on("mobileinit",
// Set up the "mobileinit" handler before requiring jQuery Mobile's module
function () {
// Prevents all anchor click handling including the addition of active button state and alternate link bluring.
$.mobile.linkBindingEnabled = false;
// Disabling this will prevent jQuery Mobile from handling hash changes
$.mobile.hashListeningEnabled = false;
}
);
if(Modernizr.touch) {
$(document).on("click", function(event) {
event.preventDefault();
});
}
require([ "jquery-mobile" ], function () {
// Instantiates a new Backbone.js Mobile Router
this.router = new MobileRouter();
});
});
这基本上是jquery mobile附带的示例的精确副本。但正如您所看到的,我在路径中有“jquerymobile”,它位于底部附近的嵌套require中
我的app.build.js如下所示:
({
"appDir": "../",
"baseUrl":"js",
"dir":"../../dist",
"mainConfigFile": "../js/main.js",
"modules": [
{
"name": "main"
}
],
"skipDirOptimize": true,
"optimizeCss": "standard"
})
运行以下命令后:
r.js -o app/build/app.build.js
我看到除了jquery-mobile.js之外,所有内容都被混入main.js。当我访问已编译的站点时,我发现唯一正在被提取的JS文件是:requirejs.JS、main.JS和jquery-mobile.JS
为什么jquery mobile没有像其他脚本一样被缩小?有趣的问题。你们能在你们的路径中指向已经缩小的版本吗?我当然能,但它不能和main.js中的其他版本结合(当试图最小化对服务器的请求数量时)。