I'm submitting a bug report
Webpack Version:
2.6.1
Babel Core Version:
6.25.0
Babel Loader Version:
7.0.0
Please tell us about your environment:
OSX 10.x
Current behavior:
the "node_modules" folder is out of the project directory, but I cannot resolve plugin at correct path by using the webpack config "resolveLoader",
got error " Unknown plugin "transform-react-jsx" specified in "base" at 0, attempted to resolve relative to..."
webpack config
resolveLoader : {
path.resolve( __dirname, '../node_modules' )
}
That setting does not affect plugin loading. You'll need to manually resolve the plugins to absolute paths when passing them to babel-loader.
@loganfsmyth thank you for ur answer ,would u please tell me how to manually resolve the plugins with webpack 2.6.1 ? like using "require.resolve", it seems like that "require.resolve" has already not been supported in webpack 2.x
@mingxian, I found a solution that worked for me with this answer:
https://github.com/babel/babel-loader/issues/313#issuecomment-259713419
@mingxian a similar problem has occurred to a few people. It seems the link that @dbethel provided is no longer working (at least not for me).
I've seen a solution similar to this when dealing with packages that are external to your project directory. This needs to be specified in your webpack.config.js, perhaps this will help:
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
query: {
presets: [
require.resolve('babel-preset-es2015')
]
}
}
]
},
I'm triaging old issues on babel-loader. Since this has been inactive for ages, I'm going to close it. Feel free to re-open if there's still something to discuss, but I'm assuming at this point it's been too long to address in a useful way.
Babel 7 should also behave better around this stuff, so hopefully manually calling require.resolve will be less common
Most helpful comment
@mingxian a similar problem has occurred to a few people. It seems the link that @dbethel provided is no longer working (at least not for me).
I've seen a solution similar to this when dealing with packages that are external to your project directory. This needs to be specified in your webpack.config.js, perhaps this will help: