react-templates是分离模板和逻辑代码的好方法,但是,如果我有多个模板但引用一个逻辑代码,如i18n请求。 例如
post.js //which is the logic code
post.en.rt //which is the template for english
post.es.rt //for spanish
如何加载post.js?
PS:我不想在post.js中加载所有语言模板,这将是一个大文件,这对网络来说是浪费
答案 0 :(得分:0)
最后,我使用带有regexp的bundle loader来解决我的问题。
像这样的代码
{
test: /(en|cn)\.rt$/,
loaders: [
"bundle?regExp=(en|cn)\.rt$&name=[1]",
"react-templates-loader"
]
},
然后所有xxx.en.rt文件将捆绑到一个en.js
中