Skip to content

Commit

Permalink
feat(v2): only create one css file to avoid code-split css loading pr…
Browse files Browse the repository at this point in the history
…oblem
  • Loading branch information
endiliey committed Nov 17, 2019
1 parent 6204d9a commit 0601bf9
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,32 @@ export function createBaseConfig(
}),
]
: undefined,
splitChunks: {
// Since the chunk name includes all origin chunk names it’s recommended for production builds with long term caching to NOT include [name] in the filenames
name: false,
cacheGroups: {
// disable the built-in cacheGroups
default: false,
common: {
name: 'common',
minChunks: totalPages > 2 ? totalPages * 0.5 : 2,
priority: 40,
splitChunks: isServer
? false
: {
// Since the chunk name includes all origin chunk names it’s recommended for production builds with long term caching to NOT include [name] in the filenames
name: false,
cacheGroups: {
// disable the built-in cacheGroups
default: false,
common: {
name: 'common',
minChunks: totalPages > 2 ? totalPages * 0.5 : 2,
priority: 40,
},
// Only create one CSS file to avoid
// problems with code-split CSS loading in different orders
// causing inconsistent/non-determanistic styling
// See https://github.com/facebook/docusaurus/issues/2006
styles: {
name: 'styles',
test: /\.css$/,
chunks: `all`,
enforce: true,
priority: 50,
},
},
},
},
},
},
module: {
rules: [
Expand Down Expand Up @@ -163,7 +176,6 @@ export function createBaseConfig(
plugins: [
new MiniCssExtractPlugin({
filename: isProd ? '[name].[contenthash:8].css' : '[name].css',
chunkFilename: isProd ? '[name].[contenthash:8].css' : '[name].css',
}),
],
};
Expand Down

0 comments on commit 0601bf9

Please sign in to comment.