Skip to content

Commit 8698b92

Browse files
committed
add webpack-stats-plugin
1 parent 05a186a commit 8698b92

File tree

5 files changed

+267095
-10
lines changed

5 files changed

+267095
-10
lines changed

gatsby-config.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
import type { GatsbyConfig } from "gatsby"
2-
import { RelativeCiAgentWebpackPlugin } from "@relative-ci/agent"
3-
4-
exports.onCreateWebpackConfig = ({ stage, actions }) => {
5-
if (stage === "build-javascript") {
6-
actions.setWebpackConfig({
7-
plugins: [new RelativeCiAgentWebpackPlugin()],
8-
})
9-
}
10-
}
112

123
const config: GatsbyConfig = {
134
siteMetadata: {

gatsby-node.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ require("dotenv").config({
1212
path: `.env.${process.env.NODE_ENV}`,
1313
})
1414

15+
import { RelativeCiAgentWebpackPlugin } from "@relative-ci/agent"
16+
import { StatsWriterPlugin } from "webpack-stats-plugin"
17+
1518
export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"] =
1619
async ({ actions }) => {
1720
const gql = String.raw
@@ -537,12 +540,27 @@ export const createPages: GatsbyNode["createPages"] = async ({
537540
}
538541

539542
export const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] =
540-
async ({ actions }) => {
543+
async ({ actions, stage }) => {
541544
actions.setWebpackConfig({
542545
resolve: {
543546
fallback: {
544547
assert: "assert/",
545548
},
546549
},
547550
})
551+
if (stage === "build-javascript") {
552+
actions.setWebpackConfig({
553+
plugins: [
554+
new RelativeCiAgentWebpackPlugin(),
555+
new StatsWriterPlugin({
556+
filename: "../webpack-stats.json",
557+
stats: {
558+
assets: true,
559+
chunks: true,
560+
modules: true,
561+
},
562+
}),
563+
],
564+
})
565+
}
548566
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"timeago.js": "4.0.2"
5858
},
5959
"devDependencies": {
60+
"webpack-stats-plugin": "1.1.3",
6061
"@relative-ci/agent": "4.2.8",
6162
"@svgr/webpack": "^8.0.0",
6263
"@tailwindcss/typography": "0.5.9",

0 commit comments

Comments
 (0)