Do not copy source file when optimizing using requirejs

断了今生、忘了曾经 提交于 2019-12-07 06:35:20

问题


When using require.js (r.js) to optimize js code, all js source code are copied to destination directory(dir property).

Is there a way (some configuration) to prevent requirejs to copy source files?


回答1:


If you add removeCombined: true to your r.js build config the optimizer will remove (essentially not copy) all source files that were combined into your output module(s).

Alternately, if you are referring to source files that are not part of the requireJS build at all, try using fileExclusionRegExp: /^\./ in your config.

See the example full r.js config file for more details.




回答2:


As rharper mentioned you have to use this property:

fileExclusionRegExp

For example if you use cssmin to concat/minify your files and don't want requirejs to move your stylesheets, and if you have let's say another folder foo you can use:

fileExclusionRegExp: /css|foo/

to exclude these folders from being copied to your build directory.




回答3:


use this config:

keepBuildDir: true,

this can keep output dir

detail: https://github.com/jrburke/r.js/blob/master/build/example.build.js#L70



来源:https://stackoverflow.com/questions/11897286/do-not-copy-source-file-when-optimizing-using-requirejs

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