RequireJS:防止复制文字!内联后的文件

时间:2015-02-26 23:33:34

标签: javascript requirejs r.js

我有一个r.js构建工作。但是,它会将template/目录下的所有文件复制到dist/目录,即使它内联了所有文本。我设置了removeCombined: true,我希望能阻止这种情况。

如果我在我的fileExclusionRegExp中包含template/目录,那么我的构建失败。我尝试用empty:排除,但没有取得多大成功。

这可能吗?或者,如果我想内联它们,我是否需要一个后期构建步骤来清理这些文件?

requirejs: {
    production: {
        //  All r.js options can be found here: https://github.com/jrburke/r.js/blob/master/build/example.build.js
        options: {
            appDir: 'src',
            dir: 'dist/',
            //  Inlines the text for any text! dependencies, to avoid the separate
            //  async XMLHttpRequest calls to load those dependencies.
            inlineText: true,
            stubModules: ['text'],
            useStrict: true,
            mainConfigFile: 'src/js/common/requireConfig.js',
            //  List the modules that will be optimized. All their immediate and deep
            //  dependencies will be included in the module's file when the build is done
            modules: [{
                name: 'background/main',
                include: ['background/plugins']
            }, {
                name: 'background/application',
                exclude: ['background/main']
            }, {
                name: 'foreground/main',
                include: ['foreground/plugins']
            }, {
                name: 'foreground/application',
                exclude: ['foreground/main']
            }],
            //  Skip optimizins because there's no load benefit for an extension and it makes error debugging hard.
            optimize: 'none',
            optimizeCss: 'none',
            preserveLicenseComments: false,
            //  Don't leave a copy of the file if it has been concatenated into a larger one.
            removeCombined: true,
            fileExclusionRegExp: /^\.|vsdoc.js$|\.example$|test|test.html|less$/
        }
    }
}

1 个答案:

答案 0 :(得分:0)

好吧,10个月之后,我对同一个项目提出了同样的问题。

假设这可能,并且应该使用文件排除正则表达式。但是,这很可怕,因为它可能会排除未通过文本加载的文件!