Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
feat(next-css): Support extra options for extract-css-chunks-webpack-…
Browse files Browse the repository at this point in the history
…plugin
  • Loading branch information
Julien Tanay committed Jul 22, 2019
1 parent 087e8e3 commit 36ac834
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/next-css/css-loader-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = (
dev,
isServer,
postcssLoaderOptions = {},
loaders = []
loaders = [],
extractCssOptions = {}
}
) => {
// We have to keep a list of extensions for the splitchunk config
Expand All @@ -33,7 +34,7 @@ module.exports = (

if (!isServer && !extractCssInitialized) {
config.plugins.push(
new ExtractCssChunks({
new ExtractCssChunks(Object.assign({}, {
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: dev
Expand All @@ -43,7 +44,8 @@ module.exports = (
? 'static/chunks/[name].chunk.css'
: 'static/chunks/[name].[contenthash:8].chunk.css',
hot: dev
})
},
extractCssOptions))
)
extractCssInitialized = true
}
Expand Down
3 changes: 2 additions & 1 deletion packages/next-css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ module.exports = (nextConfig = {}) => {
}

const { dev, isServer } = options
const { cssModules, cssLoaderOptions, postcssLoaderOptions } = nextConfig
const { cssModules, cssLoaderOptions, postcssLoaderOptions, extractCssOptions } = nextConfig

options.defaultLoaders.css = cssLoaderConfig(config, {
extensions: ['css'],
cssModules,
cssLoaderOptions,
postcssLoaderOptions,
extractCssOptions,
dev,
isServer
})
Expand Down
2 changes: 1 addition & 1 deletion packages/next-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "zeit/next-plugins",
"dependencies": {
"css-loader": "^2.1.0",
"extract-css-chunks-webpack-plugin": "^3.3.2",
"extract-css-chunks-webpack-plugin": "^4.5.6",
"find-up": "^3.0.0",
"ignore-loader": "~0.1.2",
"optimize-css-assets-webpack-plugin": "^5.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/next-sass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ module.exports = (nextConfig = {}) => {
cssModules,
cssLoaderOptions,
postcssLoaderOptions,
sassLoaderOptions = {}
sassLoaderOptions = {},
extractCssOptions
} = nextConfig

options.defaultLoaders.sass = cssLoaderConfig(config, {
extensions: ['scss', 'sass'],
cssModules,
cssLoaderOptions,
postcssLoaderOptions,
extractCssOptions,
dev,
isServer,
loaders: [
Expand Down

0 comments on commit 36ac834

Please sign in to comment.