From 17e36fd3e5cd12e32b42aa59f41dcb8875ef68c9 Mon Sep 17 00:00:00 2001 From: Benjamin Stepp Date: Sat, 7 May 2016 13:24:09 -0500 Subject: [PATCH] Use babel-presets by default This change makes it so the user doesn't need to specify their plugins. If they want to override it they would need to modify the js loader config using the modifyWebpackConfig API. Ideally we would support a user provided .babelrc as well. ``` exports.modifyWebpackConfig = function(config, env) { config.removeLader('js') config.loader('js', { test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel', query: { presets: [ 'babel-preset-react', 'babel-preset-es2015', 'babel-preset-stage-0', ].map(require.resolve), plugins: [ 'babel-plugin-add-module-exports', 'babel-plugin-transform-decorators-legacy', ].map(require.resolve), }, }) return config; } ``` Fixes #235. Requires less user package.json dependencies unless the user wants to add babel plugins (Users no longer need to provide babel-plugins of any kind in their project as gatsby provides them) --- lib/utils/webpack.config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/utils/webpack.config.js b/lib/utils/webpack.config.js index 0f836f8d0b6a8..caf6b22e568cd 100644 --- a/lib/utils/webpack.config.js +++ b/lib/utils/webpack.config.js @@ -155,7 +155,14 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) => exclude: /(node_modules|bower_components)/, loader: 'babel', query: { - plugins: ['add-module-exports'], + presets: [ + 'babel-preset-react', + 'babel-preset-es2015', + 'babel-preset-stage-0', + ].map(require.resolve), + plugins: [ + 'babel-plugin-add-module-exports', + ].map(require.resolve), }, }) config.loader('coffee', {