@@ -19,13 +19,39 @@ Need to extend the Babel configuration further? The easiest way is via
1919 // first, install any presets you want to use (e.g. yarn add babel-preset-es2017)
2020 // then, modify the default Babel configuration
2121 .configureBabel (function (babelConfig ) {
22+ // add additional presets
2223 babelConfig .presets .push (' es2017' );
24+
25+ // no plugins are added by default, but you can add some
26+ // babelConfig.plugins = ['styled-jsx/babel'];
2327 })
2428 ;
2529
26- You can also create a standard ``.babelrc `` file at the root of your project.
27- Just make sure to configure it with all the presets you need: as soon as a
28- ``.babelrc `` is present, Encore can no longer add *any * Babel configuration for
29- you!
30+ Creating a .babelrc File
31+ ------------------------
32+
33+ Instead of calling ``configureBabel() ``, you could create a ``.babelrc `` file
34+ at the root of your project. This is a more "standard" way of configuring
35+ Babel, but it has a downside: as soon as a ``.babelrc `` file is present,
36+ **Encore can no longer add any Babel configuration for you **. For example,
37+ if you call ``Encore.enableReactPreset() ``, the ``react `` preset will *not *
38+ automatically be added to Babel: you must add it yourself in ``.babelrc ``.
39+
40+ An example ``.babelrc `` file might look like this:
41+
42+ .. code-block :: json
43+
44+ {
45+ presets: [
46+ ['env', {
47+ modules: false,
48+ targets: {
49+ browsers: '> 1%',
50+ uglify: true
51+ },
52+ useBuiltIns: true
53+ } ]
54+ ]
55+ }
3056
3157 .. _`Babel` : http://babeljs.io/
0 commit comments