Skip to content

Commit b291ac6

Browse files
committed
Improve webpack config customization
1 parent 18bacea commit b291ac6

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,20 @@ For custom configuration you can create a `graphpack` config file in [cosmiconfi
236236

237237
### Customize Webpack configuration
238238

239-
To extend webpack, you can define a function that extends its config via `graphpack.config.js`.
239+
To extend webpack, you can define a function that extends its config via the config file:
240+
241+
```js
242+
// graphpack.config.js
243+
module.exports = {
244+
webpack: ({ config, webpack }) => {
245+
// Add customizations to config
246+
// Important: return the modified config
247+
return config;
248+
},
249+
};
250+
```
251+
252+
> Note that this file is not going through babel transformation.
240253
241254
## Acknowledgements
242255

packages/graphpack/config/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const cosmiconfig = require('cosmiconfig');
2+
const webpack = require('webpack');
23
const defaultConfig = require('./webpack.config');
34

45
const explorer = cosmiconfig('graphpack').search();
@@ -12,7 +13,7 @@ const loadWebpackConfig = async () => {
1213
: {};
1314

1415
if (typeof userConfig.webpack === 'function') {
15-
return userConfig.webpack(defaultConfig);
16+
return userConfig.webpack({ config: defaultConfig, webpack });
1617
}
1718

1819
return defaultConfig;

0 commit comments

Comments
 (0)