Skip to content

Commit 7f789ac

Browse files
authored
feat: add compression (#317)
* feat: add compression * pkg: lock compression
1 parent 4da2f5c commit 7f789ac

File tree

6 files changed

+4448
-9637
lines changed

6 files changed

+4448
-9637
lines changed

.github/workflows/deploy-landing-page.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
cd ./docs/
2929
pm2 restart graphql-debugger.com
3030
cd ../apps/ui
31-
DEMO_MODE=true pnpm build
31+
NODE_ENV=production DEMO_MODE=true pnpm build
3232
pm2 restart demo

apps/backend/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"dev": "cross-env TRACE_SCHEMA=true TRACE_PRISMA=true TRACE_EXPRESS=true ts-node ./src/main.ts"
1919
},
2020
"dependencies": {
21-
"@graphql-debugger/client": "workspace:^",
2221
"@graphql-debugger/adapter-sqlite": "workspace:^",
22+
"@graphql-debugger/client": "workspace:^",
2323
"@graphql-debugger/graphql-schema": "workspace:^",
2424
"@graphql-debugger/plugin-express": "workspace:^",
2525
"@graphql-debugger/ui": "workspace:^",
2626
"@graphql-debugger/utils": "workspace:^",
2727
"cors": "2.8.5",
28-
"express": "4.19.2"
28+
"express": "4.19.2",
29+
"express-static-gzip": "2.1.7"
2930
},
3031
"devDependencies": {
3132
"@types/cors": "2.8.17",

apps/backend/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { graphqlDebugger } from "@graphql-debugger/plugin-express";
44

55
import cors from "cors";
66
import express, { Express } from "express";
7+
import expressStaticGzip from "express-static-gzip";
78
import http from "http";
89
import path from "path";
910

@@ -30,7 +31,12 @@ export async function start({
3031
client,
3132
}),
3233
);
33-
app.use(express.static(path.join(__dirname, "../../ui/build")));
34+
app.use(
35+
"/",
36+
expressStaticGzip(path.join(__dirname, "../../ui/build"), {
37+
enableBrotli: true,
38+
}),
39+
);
3440
app.use(express.static("public"));
3541

3642
const server = await app.listen(port);

apps/ui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
},
4848
"devDependencies": {
4949
"@faker-js/faker": "8.4.1",
50-
"@graphql-debugger/types": "workspace:^"
50+
"@graphql-debugger/types": "workspace:^",
51+
"compression-webpack-plugin": "11.1.0"
5152
},
5253
"engines": {
5354
"node": ">=18",

apps/ui/webpack.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
44
const CopyWebpackPlugin = require("copy-webpack-plugin");
55
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
66
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
7+
const CompressionPlugin = require("compression-webpack-plugin");
78

89
module.exports = {
910
mode: "none",
@@ -73,6 +74,13 @@ module.exports = {
7374
favicon: "./public/favicon.svg",
7475
}),
7576
new NodePolyfillPlugin(),
77+
...(process.env.NODE_ENV === "production"
78+
? [
79+
new CompressionPlugin({
80+
deleteOriginalAssets: true,
81+
}),
82+
]
83+
: []),
7684
],
7785
devServer: {
7886
static: {

0 commit comments

Comments
 (0)