Exclude all starting with x in requirejs module

大城市里の小女人 提交于 2019-12-10 18:32:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!