I have this Babel loader that\'s working
{ test: /\\.jsx?$/, loader: \'babel\', query: babelSettings, exclude: /node_modules/ },
But now I
Update: With non-legacy versions of Webpack you can define an array of loaders in the Webpack configuration.
If you need to use an older versions of Webpack or add the options inline, the original answer is below.
The way to do this is to set the query parameters in the loader string itself, as the query
object key will only work for one loader.
Assuming your settings object can be serialized to JSON, as your example indicates, you could easily pass your settings object as a JSON query. Then only the Babel loader will get the settings.
{ test: /\.coffee$/, loader: 'babel?'+JSON.stringify(babelSettings)+'!coffee', exclude: /node_modules/ }
The feature for doing this is somewhat documented here:
Using Loaders: Query parameters
Most loaders accept parameters in the normal query format (
?key=value&key2=value2
) and as JSON object (?{"key":"value","key2":"value2"}
).