编程语言
首页 > 编程语言> > javascript-r.js-从编译/缩小过程中排除某些模块

javascript-r.js-从编译/缩小过程中排除某些模块

作者:互联网

在开发Web应用程序时,我更希望性能接近生产质量.目前,我的小项目基于Requirejs,因此我正在尝试通过使用r.js来实现我的目标.在一种情况下,我想从编译/缩小过程中排除一些模块(文件),但是我不知道该怎么做.目前,我有一个下一个构建脚本:

 ({
    mainConfigFile : "../app/js/main.js",
    appDir: "../app",
    baseUrl: "js",
    optimizeCss: "standard",
    fileExclusionRegExp: /\.git/,
    dir: "dist",
    modules: [
        {
            name: "main",
            exclude: [
                "infrastructure",
                "modules/app"

            ]
        }
    ]
})

那么我应该怎么做才能从编译/缩小过程中排除某些模块(文件),例如jquery模块呢?

解决方法:

将您要排除的模块设置为空:

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:"
    }
})

标签:requirejs,r-js,javascript
来源: https://codeday.me/bug/20191120/2044295.html