Skip to content

Commit 2dac972

Browse files
committed
fixup! feat(site): configure global fonts
1 parent 594006c commit 2dac972

File tree

4 files changed

+523
-23
lines changed

4 files changed

+523
-23
lines changed

site/package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
"@material-ui/core": "4.9.4",
2929
"@material-ui/icons": "4.5.1",
3030
"@material-ui/lab": "4.0.0-alpha.42",
31-
"@xstate/react": "^2.0.1",
31+
"@xstate/react": "2.0.1",
3232
"axios": "0.26.1",
3333
"formik": "2.2.9",
3434
"history": "5.3.0",
3535
"react": "17.0.2",
3636
"react-dom": "17.0.2",
3737
"react-router-dom": "6.2.2",
3838
"swr": "1.2.2",
39-
"xstate": "^4.30.6",
39+
"xstate": "4.30.6",
4040
"yup": "0.32.11"
4141
},
4242
"devDependencies": {
@@ -49,15 +49,17 @@
4949
"@storybook/react": "6.4.19",
5050
"@testing-library/react": "12.1.4",
5151
"@types/express": "4.17.13",
52-
"@types/jest": "^27.4.1",
52+
"@types/jest": "27.4.1",
5353
"@types/node": "14.18.12",
5454
"@types/react": "17.0.40",
5555
"@types/react-dom": "17.0.13",
5656
"@types/superagent": "4.1.15",
5757
"@typescript-eslint/eslint-plugin": "5.15.0",
5858
"@typescript-eslint/parser": "5.15.0",
59-
"@xstate/cli": "^0.1.4",
59+
"@xstate/cli": "0.1.4",
6060
"copy-webpack-plugin": "10.2.4",
61+
"css-loader": "6.7.1",
62+
"css-minimizer-webpack-plugin": "3.4.1",
6163
"eslint": "8.11.0",
6264
"eslint-config-prettier": "8.5.0",
6365
"eslint-import-resolver-alias": "1.1.2",
@@ -73,10 +75,12 @@
7375
"jest": "27.5.1",
7476
"jest-junit": "13.0.0",
7577
"jest-runner-eslint": "1.0.0",
76-
"msw": "^0.39.2",
78+
"mini-css-extract-plugin": "2.6.0",
79+
"msw": "0.39.2",
7780
"prettier": "2.6.0",
7881
"react-hot-loader": "4.13.0",
7982
"sql-formatter": "4.0.2",
83+
"style-loader": "3.3.1",
8084
"ts-jest": "27.1.3",
8185
"ts-loader": "9.2.8",
8286
"ts-node": "10.7.0",

site/webpack.dev.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { commonWebpackConfig } from "./webpack.common"
1010

1111
const commonPlugins = commonWebpackConfig.plugins || []
1212

13+
const commonRules = commonWebpackConfig.module?.rules || []
14+
1315
const config: Configuration = {
1416
...commonWebpackConfig,
1517

@@ -68,6 +70,20 @@ const config: Configuration = {
6870
// https://webpack.js.org/configuration/mode/#mode-development
6971
mode: "development",
7072

73+
module: {
74+
rules: [
75+
...commonRules,
76+
77+
{
78+
test: /\.css$/i,
79+
// Use simple style-loader for CSS modules. This places styles directly
80+
// in <style> tags which is great for development, but poor for loading
81+
// in production
82+
use: ["style-loader", "css-loader"],
83+
},
84+
],
85+
},
86+
7187
output: {
7288
...commonWebpackConfig.output,
7389

site/webpack.prod.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,46 @@
22
* @fileoverview This file contains a production configuration for webpack
33
* meant for producing optimized builds.
44
*/
5-
65
import CopyWebpackPlugin from "copy-webpack-plugin"
6+
import CSSMinimizerPlugin from "css-minimizer-webpack-plugin"
7+
import MiniCSSExtractPlugin from "mini-css-extract-plugin"
78
import { Configuration } from "webpack"
89
import { commonWebpackConfig } from "./webpack.common"
910

1011
const commonPlugins = commonWebpackConfig.plugins || []
1112

13+
const commonRules = commonWebpackConfig.module?.rules || []
14+
1215
export const config: Configuration = {
1316
...commonWebpackConfig,
17+
1418
mode: "production",
1519

1620
// Don't produce sourcemaps in production, to minmize bundle size
1721
devtool: false,
1822

23+
module: {
24+
rules: [
25+
...commonRules,
26+
// CSS files -> optimized
27+
{
28+
test: /\.css$/i,
29+
use: [MiniCSSExtractPlugin.loader, "css-loader"],
30+
},
31+
],
32+
},
33+
34+
optimization: {
35+
minimizer: [
36+
`...`, // This extends the 'default'/'existing' minimizers
37+
new CSSMinimizerPlugin(),
38+
],
39+
},
40+
1941
output: {
2042
...commonWebpackConfig.output,
2143

22-
// regenerate the entire out/ directory when producing production builds
44+
// regenerate the entire dist/ directory when producing production builds
2345
clean: true,
2446
},
2547

@@ -30,6 +52,13 @@ export const config: Configuration = {
3052
new CopyWebpackPlugin({
3153
patterns: [{ from: "static", to: "." }],
3254
}),
55+
56+
// MiniCSSExtractPlugin optimizes CSS
57+
new MiniCSSExtractPlugin({
58+
// REMARK: It's important to use [contenthash] here to invalidate caches.
59+
filename: "[name].[contenthash].css",
60+
chunkFilename: "[id].css",
61+
}),
3362
],
3463
}
3564

0 commit comments

Comments
 (0)