cacheIdentifier: Default is a string composed by the babel-core's version, the babel-loader's version, the contents of .babelrc file if it exists and the value of the environment variable BABEL_ENV with a fallback to the NODE_ENV environment variable. This can be set to a custom value to force cache busting if the identifier changes.
Sounds like I could use cacheIdentifier to use my babel settings defined in .babelrc but not sure how to use it. Please advice :)
Was about the open the same issue. I was trying to supply path to a different .babelrc file.
As far I could understand, currently you can specify an alternate .babelrc file using babelrc property (as seen here). digging deeper, it looks like it sends the contents of .babelrc files, as is, to babel.transform, instead of parsing and sending the options.
Docs say babelrc is of type boolean and not the contents of overriding .babelrc file.
Is this a bug? Or am I using the feature wrong.
From my current understanding and experience (yesterday!) the babelrc setting can be used to tell babel to use the .babelrc file as a baseline or not (true by default?)
Not sure if/how you can configure to use an alternative .babelrc file or location?
@kristianmandrup
babelrc setting can be used to tell babel to use the .babelrc file as a baseline or not
You are right. That's what I found too.
Not sure if/how you can configure to use an alternative .babelrc file or location?
I'm wondering how to do this. Docs would be helpful. Maybe I missed it. More than willing will add it myself.
It doesn't look like .babelrc contents are used at all. If you put options into the query arg they end up as part of the options, but the .babelrc contents are only used as the cacheIdentifier and have no impact on how babel ends up being used. There's no other instance of .babelrc being used anywhere in the code.
Nevermind I got it working. The error I was seeing was unrelated. You can specify another location for .babelrc. If you don't have a query option but you have a .babelrc file in the same directory as your webpack configuration it should work fine. I believe if the .babelrc is in a different place you can specify its location using the babelrc option on the query config property.
I believe if the .babelrc is in a different place you can specify its location using the babelrc option on the query config property.
Tried that, you end up with:
Module build failed: Error: .babelrc must be a boolean, or undefined
It does not look like you can set a fixed location.
You can set a base .babelrc using:
options: {
extends: path.resolve(__dirname, ".babelrc.js"),
}
Tested on Babel 8. Perfect if you are importing from outside the current working directory.
Babel should now pick up the contents of .babelrc files and such when caching with babel-loader, so it seems like this is mostly resolved.
@loganfsmyth I've not been able to get [email protected] to recognize my .babelrc files in my app folder. I run webpack from my project root and I have a project setup like this:
ProjectRoot/
babel.config.js
app/desktop/.babelrc
webpack_configs/.babelrc
~~The full project has more folders and more .babelrc files, which is why I'm using babel.config.js. ~~
From what I understand Babel-Loader should pick up the .babelrc in the app/desktop folder from what I can tell, but instead I get errors resulting from none of the plugins/presets being defined. I've been defining these in parallel in my webpack config, but I'm trying to dry things up.
I didn't want to make a new issue for something that's already been discussed to death, but I also can't find a solution among any of the discussions. If you have any ideas I'd really appreciate it!
Looks like my problem is probably with on of my .babelrc files
Most helpful comment
Tried that, you end up with:
It does not look like you can set a fixed location.You can set a base
.babelrcusing:Tested on Babel 8. Perfect if you are importing from outside the current working directory.