2
votes

When I enable cacheDirectory for babel-loader, I get the following error when running webpack:

Module build failed: ReferenceError: [BABEL] C:\Projects\xxx\index.js: Unknown option: base.{"presets":["react". Check out http://babeljs.io/docs/usage/options/ for more info

If I remove cacheDirectory, everything works fine. Does anyone know what I'm missong

My loader looks like this:

{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel?' + JSON.stringify(babelrc) + '&cacheDirectory', 'eslint'] }

My .babelrc looks like this:

{
 "presets": [
  "react",
  "es2015",
  "stage-0"
 ]
}
1

1 Answers

3
votes

Looks like you are mixing JSON style configuration and query string style configuration in you babel-loader config.

Try this:

{
  test: /\.jsx?$/,
  exclude: /node_modules/,
  loaders: [
    'babel?' + JSON.stringify(
      Object.assign({}, babelrc, {cacheDirectory: true})
    ),
    'aslant
  ]
}

Also what's babelrc variable? I think if you have .babelrc in your package dir babe-loader will pick up it automatically.