r.js - 从 compilation/minification 进程中排除一些模块
r.js - exclude some modules from compilation/minification process
在开发 Web 应用程序时,我希望性能更接近生产质量。目前我的小项目是基于 Requirejs 的,所以我正在尝试通过使用 r.js 来实现我的目标。在一种情况下,我想从 compilation/minification 进程中排除一些模块(文件),但我不知道该怎么做。目前我有下一个构建脚本:
({
mainConfigFile : "../app/js/main.js",
appDir: "../app",
baseUrl: "js",
optimizeCss: "standard",
fileExclusionRegExp: /\.git/,
dir: "dist",
modules: [
{
name: "main",
exclude: [
"infrastructure",
"modules/app"
]
}
]
})
那么我应该如何从 compilation/minification 进程中排除一些模块(文件),例如 jquery 模块?
将您希望排除的模块设置为具有路径 empty:
。
http://requirejs.org/docs/optimization.html#empty
If the script does not have any dependencies, or you do not want to include its dependencies or will be including them in another way, then you can use the special 'empty:' scheme in the paths config to just skip the file when doing an optimization.
构建配置文件示例:
({
baseUrl: ".",
name: "main",
out: "main-built.js",
paths: {
jquery: "empty:"
}
})
在开发 Web 应用程序时,我希望性能更接近生产质量。目前我的小项目是基于 Requirejs 的,所以我正在尝试通过使用 r.js 来实现我的目标。在一种情况下,我想从 compilation/minification 进程中排除一些模块(文件),但我不知道该怎么做。目前我有下一个构建脚本:
({
mainConfigFile : "../app/js/main.js",
appDir: "../app",
baseUrl: "js",
optimizeCss: "standard",
fileExclusionRegExp: /\.git/,
dir: "dist",
modules: [
{
name: "main",
exclude: [
"infrastructure",
"modules/app"
]
}
]
})
那么我应该如何从 compilation/minification 进程中排除一些模块(文件),例如 jquery 模块?
将您希望排除的模块设置为具有路径 empty:
。
http://requirejs.org/docs/optimization.html#empty
If the script does not have any dependencies, or you do not want to include its dependencies or will be including them in another way, then you can use the special 'empty:' scheme in the paths config to just skip the file when doing an optimization.
构建配置文件示例:
({
baseUrl: ".",
name: "main",
out: "main-built.js",
paths: {
jquery: "empty:"
}
})