RequireJS:防止复制文本!内联后的文件
RequireJS: Prevent copying text! files after inline
我有一个 r.js 构建可以工作。但是,它会将我的 template/
目录下的所有文件复制到 dist/
目录,即使它内联了它们的所有文本。我有 removeCombined: true
设置,我希望可以防止这种情况发生。
如果我在 fileExclusionRegExp 中包含 template/
目录,那么我的构建将失败。我尝试使用 empty:
进行排除,但收效甚微。
这可能吗?或者,如果我想内联这些文件,是否需要 post-build 步骤来清理这些文件?
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$/
}
}
}
嗯,10 个月后,我对另一个项目有同样的问题。
假设这不可能并且应该使用文件排除正则表达式。然而,这很可怕,因为它可能会排除未通过文本加载的文件!
我有一个 r.js 构建可以工作。但是,它会将我的 template/
目录下的所有文件复制到 dist/
目录,即使它内联了它们的所有文本。我有 removeCombined: true
设置,我希望可以防止这种情况发生。
如果我在 fileExclusionRegExp 中包含 template/
目录,那么我的构建将失败。我尝试使用 empty:
进行排除,但收效甚微。
这可能吗?或者,如果我想内联这些文件,是否需要 post-build 步骤来清理这些文件?
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$/
}
}
}
嗯,10 个月后,我对另一个项目有同样的问题。
假设这不可能并且应该使用文件排除正则表达式。然而,这很可怕,因为它可能会排除未通过文本加载的文件!