2017-02-24 25 views
0

我使用的是react-native-web,我遇到了几个不编译babel代码的项目(react-native-popoverreact-native-vector-icons)。所以我需要编译这些node_modules。我知道babel-preset-react-native预设存在。有没有什么方法可以使用我目前使用的babel loader(见下文),还包括上述软件包的另一个加载器?理想情况下,任何以react-native开头的node_module将使用babel-preset-react-native加载。如何包含特定的node_modules加载到webpack?

{ 
    test: /\.js$/, 
    exclude: /node_modules/, 
    loaders: [ 
     'react-hot', 
     'babel-loader?cacheDirectory=true' 
    ] 
    }, 
+0

'exclude:/ node_modules /'这里是你的答案 –

+0

什么?这将包括我不想要的所有模块。 – ThomasReggi

+0

你说得对,我应该更精确:提示你的答案 –

回答

3

排除需要正则表达式。你可以使用这样的东西来获得你想要的效果。

exclude: /node_modules\/(?!react-native)/ 
相关问题