Skip to content

Commit

Permalink
Allow webpack config to accept babel presets & plugins via env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
philiptzou committed Oct 13, 2016
1 parent dc6074a commit e48b4f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var publicPath = '/';
var publicUrl = '';
// Get enrivonment variables to inject into our app.
var env = getClientEnvironment(publicUrl);
var babelPresets = process.env.BABEL_PRESETS || '[]';
babelPresets = JSON.parse(babelPresets);
var babelPlugins = process.env.BABEL_PLUGINS || '[]';
babelPlugins = JSON.parse(babelPlugins);

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
Expand Down Expand Up @@ -119,7 +123,8 @@ module.exports = {
query: {
// @remove-on-eject-begin
babelrc: false,
presets: [require.resolve('babel-preset-react-app')],
presets: [require.resolve('babel-preset-react-app')].concat(babelPresets),
plugins: babelPlugins,
// @remove-on-eject-end
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/react-scripts/
Expand Down
7 changes: 6 additions & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ var publicPath = ensureSlash(homepagePathname, true);
var publicUrl = ensureSlash(homepagePathname, false);
// Get enrivonment variables to inject into our app.
var env = getClientEnvironment(publicUrl);
var babelPresets = process.env.BABEL_PRESETS || '[]';
babelPresets = JSON.parse(babelPresets);
var babelPlugins = process.env.BABEL_PLUGINS || '[]';
babelPlugins = JSON.parse(babelPlugins);

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
Expand Down Expand Up @@ -123,7 +127,8 @@ module.exports = {
// @remove-on-eject-begin
query: {
babelrc: false,
presets: [require.resolve('babel-preset-react-app')],
presets: [require.resolve('babel-preset-react-app')].concat(babelPresets),
plugins: babelPlugins
},
// @remove-on-eject-end
},
Expand Down
8 changes: 4 additions & 4 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "react-scripts",
"name": "@philiptzou/react-scripts",
"version": "0.6.1",
"description": "Configuration and scripts for Create React App.",
"repository": "facebookincubator/create-react-app",
"description": "Configuration and scripts for Create React App. Customized by Stanford HIVDB team.",
"repository": "philiptzou/create-react-app",
"license": "BSD-3-Clause",
"engines": {
"node": ">=4"
},
"bugs": {
"url": "https://github.com/facebookincubator/create-react-app/issues"
"url": "https://github.com/philiptzou/create-react-app/issues"
},
"files": [
".babelrc",
Expand Down

0 comments on commit e48b4f4

Please sign in to comment.