File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,23 @@ module.exports = {
249249};
250250```
251251
252+ ### Customize Babel configuration
253+
254+ Add an optional ` babel.config.js ` to your project root with the following preset
255+
256+ ``` js
257+ // babel.config.js
258+ module .exports = api => {
259+ // Cache the returned value forever and don't call this function again
260+ api .cache (true );
261+
262+ return {
263+ presets: [' graphpack/babel' ],
264+ // ... Add your plugins and custom config
265+ };
266+ };
267+ ```
268+
252269> Note that this file is not going through babel transformation.
253270
254271## Acknowledgements
Original file line number Diff line number Diff line change 11const FriendlyErrorsWebpackPlugin = require ( 'friendly-errors-webpack-plugin' ) ;
2+ const fs = require ( 'fs' ) ;
23const path = require ( 'path' ) ;
34const webpack = require ( 'webpack' ) ;
45const nodeExternals = require ( 'webpack-node-externals' ) ;
56
67const IS_DEV = process . env . NODE_ENV !== 'production' ;
8+ const hasBabelRc = fs . existsSync ( path . resolve ( 'babel.config.js' ) ) ;
9+
10+ if ( hasBabelRc ) {
11+ console . info ( '🐠 Using .babelrc defined in your app root' ) ;
12+ }
713
814module . exports = {
915 devtool : 'sourcemap' ,
1016 entry : {
11- // We take care of setting up entry file under lib/server .js
17+ // We take care of setting up entry file under lib/index .js
1218 index : [ 'graphpack' ] ,
1319 } ,
1420 // When bundling with Webpack for the backend you usually don't want to bundle
@@ -30,7 +36,9 @@ module.exports = {
3036 options : {
3137 babelrc : true ,
3238 cacheDirectory : true ,
33- presets : [ require . resolve ( 'babel-preset-graphpack' ) ] ,
39+ presets : hasBabelRc
40+ ? undefined
41+ : [ require . resolve ( 'babel-preset-graphpack' ) ] ,
3442 } ,
3543 } ,
3644 ] ,
Original file line number Diff line number Diff line change 1+ module . exports = require ( 'babel-preset-graphpack' ) ;
You can’t perform that action at this time.
0 commit comments