Skip to content

webpack picks up .babelrc on netlify deploy but not locally? #152

Closed
@omonk

Description

@omonk

Whilst trying to deploy on Netlify I get an error relating to babel-preset-gatsby being loaded by webpack.

4:51:44 PM: Module build failed (from /opt/build/repo/node_modules/babel-loader/lib/index.js):
4:51:44 PM: Error: [BABEL] /opt/build/repo/src/functions/meetup.js: `babel-preset-gatsby` has been loaded, which consumes config generated by the Gatsby CLI. Set `NODE_ENV=test` to bypass, or run `gatsby build` first. (While processing: "/opt/build/repo/node_modules/babel-preset-gatsby/index.js")

Makes total sense but can anyone tell me why I can't replicate this locally?

I've tried setting NODE_ENV to 'production' locally but not getting it.

"build": "run-p build:**",
"build:app": "gatsby build",
"build:lambda": "netlify-lambda -c webpack.functions.js build src/functions",

webpack config:

const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')

module.exports = {
  externals: [nodeExternals()],
  mode: 'production',
  plugins: [new webpack.DefinePlugin({ 'global.GENTLY': false })]
}

.babelrc

{
  "presets": ["babel-preset-gatsby"],
  "env": {
    "test": {
      "plugins": ["require-context-hook"]
    }
  }
}

any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions