问题
I am "compiling" some files into one requirejs module. I have a configuration like this:
paths:
lib : "../lib"
angular: "../lib/angular"
modules: [
{
name : 'myApp'
exclude: ["lib/jquery", "lib/angular"]
}
]
(syntax is cofeescript)
I want to exclude all files located under "lib" (e.g. starting with lib/) in "myApp" module. I now I can write them one another one like this: ["lib/jquery", "lib/angular"] But more libs and modules will be added in the future so some kind of automatization would be nice.
Is there any way to tell require js that "everything under lib should be excluded on myApp module"? Somethink like this:
modules: [
{
name : 'myApp'
exclude: ["lib/*"]
}
]
回答1:
I don't know of a wildcard syntax, but you can define the list of excluded files as their own module, and then exclude them by name in all future modules.
Sorry, don't speak coffeescript:
modules: [
{
name: 'core',
include: [ 'lib/jquery', 'lib/angular', 'lib/somethingelse' ]
},
{
name: 'module1',
exclude: [ 'core' ]
},
{
name: 'module2',
exclude: [ 'core' ]
}
]
来源:https://stackoverflow.com/questions/17171133/exclude-all-starting-with-x-in-requirejs-module