2017-02-24 104 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)/ 
相關問題