Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize babel with react-scripts v1 (webpack v2) #46

Closed
comerc opened this issue Jun 11, 2017 · 4 comments
Closed

How to customize babel with react-scripts v1 (webpack v2) #46

comerc opened this issue Jun 11, 2017 · 4 comments

Comments

@comerc
Copy link
Contributor

comerc commented Jun 11, 2017

before:

// config-overrides.js

function rewire(config, env) {
  const babelrc = config.module.loaders.find(conf => {
    return conf.loader === 'babel'
  }).query
  babelrc.plugins = [
    'styled-jsx-postcss/babel',
  ].concat(babelrc.plugins || [])
  return config
}

module.exports = rewire

after:

// config-overrides.js

function rewire(config, env) {
  const babelOptions = config.module.rules.find(conf => {
    return conf.loader && conf.loader.includes('babel-loader')
  }).options
  const babelrc = require(babelOptions.presets[0])
  babelrc.plugins = [
    'styled-jsx-postcss/babel',
  ].concat(babelrc.plugins || [])
  babelOptions.presets = babelrc
  return config
}

module.exports = rewire

happy coding!

@mauriciosoares
Copy link

images-1

@timarney
Copy link
Owner

timarney commented Jul 6, 2017

@comerc @mauriciosoares

You should be able to use injectBabelPlugin(pluginName, config) now.

See the config here https://github.com/timarney/mobx-rewire-test/blob/master/config-overrides.js

Will add to the Readme at some point.

@timarney timarney closed this as completed Jul 6, 2017
@comerc
Copy link
Contributor Author

comerc commented Jul 6, 2017

@timarney how about array of plugins? :)

@timarney
Copy link
Owner

timarney commented Jul 6, 2017

@comerc Feel free to give it a try you can find the code here https://github.com/timarney/react-app-rewired/blob/master/packages/react-app-rewired/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants