Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying cacheDirectory in .babelrc file

I tried:

{
    "env": {
        "development": {
            "option": {
                "cacheDirectory": true
            }
        }
    }
}

but it didn't work. I just want to enable the cacheDirectory in development environment for the faster hmr. any ideas? thanks!

like image 715
Ymin Hu Avatar asked Nov 04 '25 10:11

Ymin Hu


1 Answers

cacheDirectory is actually an option of babel-loader, not babel itself, so the babelrc config is not the right place for this option.

You can enable it in the configuration of babel-loader. One way of doing so is by using loader: 'babel-loader?cacheDirectory'.

From the babel-loader docs (emphasis my own):

This loader also supports the following loader-specific option:

  • cacheDirectory: Default false. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (loader: 'babel-loader?cacheDirectory') or true (loader: babel-loader?cacheDirectory=true) the loader will use the default cache directory in node_modules/.cache/babel-loader or fallback to the default OS temporary file directory if no node_modules folder could be found in any root directory.
like image 91
agilgur5 Avatar answered Nov 05 '25 23:11

agilgur5