Webpack需要动态路径

时间:2016-11-01 07:23:29

标签: angular webpack require

你好,当我试图动态地要求路径时,我发现模块未找到错误。但是如果相同的字符串加载正常。

工作:

require('../' + 'components/profilebanner/profile.banner.component');

不工作:

let path = '../components/profilebanner/profile.banner.component';
require(path);

我尝试使用正则表达式中的上下文和调整,但我不确定我做错了什么

上下文:

require.context('.', true, /^((?![\\/]node_modules|components[\\/]).)*\.md$/)('../components/profilebanner/profile.banner.component');

0 个答案:

没有答案
相关问题