-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.ts
More file actions
35 lines (28 loc) · 899 Bytes
/
gatsby-node.ts
File metadata and controls
35 lines (28 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { GatsbyNode } from 'gatsby';
import type { WebpackPluginInstance } from 'webpack';
interface MiniCssExtractPluginOptions {
ignoreOrder?: boolean;
[key: string]: unknown;
}
interface MiniCssExtractPlugin extends WebpackPluginInstance {
options: MiniCssExtractPluginOptions;
}
function isMiniCssExtractPlugin(
plugin: WebpackPluginInstance,
): plugin is MiniCssExtractPlugin {
return plugin?.constructor.name === 'MiniCssExtractPlugin';
}
export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({
actions,
stage,
getConfig,
}) => {
if (stage === 'build-javascript' || stage === 'develop') {
const config = getConfig();
const miniCssExtractPlugin = config.plugins?.find(isMiniCssExtractPlugin);
if (miniCssExtractPlugin) {
miniCssExtractPlugin.options.ignoreOrder = true;
}
actions.replaceWebpackConfig(config);
}
};