Javascript 生成RequireJS";捆绑;使用Grunt动态配置
根据RequireJS API,Javascript 生成RequireJS";捆绑;使用Grunt动态配置,javascript,gruntjs,requirejs,amd,Javascript,Gruntjs,Requirejs,Amd,根据RequireJS API,bundlesconfiguration属性用于将模块映射到它们的bundle文件(在生产模式下,假设在大型项目中有多个bundle) 我使用Grunt绑定r.js当然,如何根据实际绑定动态生成bundle配置?e、 g.如果模块angular绑定到common.js,则应将其添加到common绑定的模块列表中 requirejs配置的这一部分不应手动维护,因为它将导致许多错误 有什么建议吗?RequireJS的2.2.0版引入了一个编写从构建生成的bundles
bundles
configuration属性用于将模块映射到它们的bundle文件(在生产模式下,假设在大型项目中有多个bundle)
r.js
当然,如何根据实际绑定动态生成bundle
配置?e、 g.如果模块angular
绑定到common.js
,则应将其添加到common
绑定的模块列表中有什么建议吗?RequireJS的2.2.0版引入了一个编写从构建生成的
bundles
选项的方法:
//Introduced in 2.2.0. Path to file to write out bundles config
//(http://requirejs.org/docs/api.html#config-bundles) found in the module
//layers built by the optimizer. The path is relative to the "dir" config's
//path. Only applies to full project optimization:
//http://requirejs.org/docs/optimization.html#wholeproject
//Only use if the optimized layers are grouped more intricately then just
//a simple optimization of main app entry points. The file path specified
//should be to one that has the top level requirejs.config() call that sets
//up the loader. If using "mainConfigFile", then this path likely should be
//the path to that file where it is placed in the "dir" output directory.
bundlesConfigOutFile: 'some/path/to/main.js',
如果上面的选项对您不起作用,那么您必须执行我所做的操作,并滚动您自己的代码,为
捆绑包
生成适当的值。如果您使用此选项,您知道requirejs如何生成捆绑包配置吗?它从哪里获得模块之间的链接?