Skip to content

Commit a315809

Browse files
authored
Merge pull request #10 from alexandre-combemorel/master
feature/add export patch function for webpack config only
2 parents f57ce26 + be36e81 commit a315809

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

lib/index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,28 @@ function patchWebpackStyleRules(rule) {
3838
}
3939
}
4040

41+
function patchWebpackConfig(config, { isServer }) {
42+
if (isServer) {
43+
patchServerWebpackConfig(config)
44+
} else {
45+
patchClientWebpackConfig(config)
46+
}
47+
return config
48+
}
49+
4150
function withGlobalCss() {
4251
return (nextConfig) => {
4352
const config = {
4453
webpack: (config, { isServer }) => {
45-
if (isServer) {
46-
patchServerWebpackConfig(config)
47-
} else {
48-
patchClientWebpackConfig(config)
49-
}
50-
return config
54+
patchWebpackConfig(config, { isServer })
5155
},
5256
}
5357
return { ...nextConfig, ...config }
5458
}
5559
}
5660

57-
module.exports = { withGlobalCss }
61+
62+
module.exports = {
63+
withGlobalCss,
64+
patchWebpackConfig
65+
}

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ module.exports = withConfig({
3030
})
3131
```
3232

33+
**If your webpack configuration is already customized:**
34+
```js
35+
const { patchWebpackConfig } = require('next-global-css')
36+
37+
const nextConfig = {
38+
/* config options here */
39+
/* your already customized webpack option */
40+
webpack: (config, options) => {
41+
patchWebpackConfig(config, options)
42+
},
43+
}
44+
```
45+
3346
## 📜 License
3447

3548
Project is [MIT licensed](https://github.com/yarastqt/next-global-css/blob/master/license.md).

0 commit comments

Comments
 (0)