Skip to content

Commit

Permalink
Compile dependencies with babel-preset-env (facebook#3776)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and Timer committed Jan 15, 2018
1 parent ab6f23f commit 33eeb41
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ module.exports = {
name: 'static/media/[name].[hash:8].[ext]',
},
},
// Process JS with Babel.
// Process application JS with Babel.
// The preset includes JSX, Flow, and some ESnext features.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
Expand All @@ -175,6 +176,18 @@ module.exports = {
cacheDirectory: true,
},
},
// Process any JS outside of the app with Babel.
// Unlike the application JS, we only compile the standard ES features.
{
test: /\.js$/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
compact: false,
presets: [require.resolve('babel-preset-react-app/dependencies')],
cacheDirectory: true,
},
},
// "postcss" loader applies autoprefixer to our CSS.
// "css" loader resolves paths in CSS and adds assets as dependencies.
// "style" loader turns CSS into JS modules that inject <style> tags.
Expand Down
15 changes: 14 additions & 1 deletion config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ module.exports = {
name: 'static/media/[name].[hash:8].[ext]',
},
},
// Process JS with Babel.
// Process application JS with Babel.
// The preset includes JSX, Flow, and some ESnext features.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
Expand All @@ -180,6 +181,18 @@ module.exports = {
compact: true,
},
},
// Process any JS outside of the app with Babel.
// Unlike the application JS, we only compile the standard ES features.
{
test: /\.js$/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
compact: false,
presets: [require.resolve('babel-preset-react-app/dependencies')],
cacheDirectory: true,
},
},
// The notation here is somewhat confusing.
// "postcss" loader applies autoprefixer to our CSS.
// "css" loader resolves paths in CSS and adds assets as dependencies.
Expand Down

0 comments on commit 33eeb41

Please sign in to comment.