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 a8f3e58
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions packages/next-css/css-loader-config.js
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
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
4 changes: 3 additions & 1 deletion packages/next-sass/index.js
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 a8f3e58

Please sign in to comment.