Skip to content

Commit 2f82c8c

Browse files
Fixes and improvements
1 parent be604db commit 2f82c8c

File tree

8 files changed

+46
-63
lines changed

8 files changed

+46
-63
lines changed

dotcom-rendering/.storybook/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { transpileExclude, getLoaders } from '../webpack/webpack.config.client';
44
import { saveStories } from '../scripts/gen-stories/get-stories.mjs';
55
import type { StorybookConfig } from '@storybook/react-webpack5';
66
import { svgr } from '../webpack/svg.cjs';
7+
import process from 'node:process';
78

89
// Generate dynamic Card and Layout stories
910
saveStories();
@@ -14,7 +15,6 @@ const config: StorybookConfig = {
1415
backgrounds: true,
1516
controls: true,
1617
viewport: true,
17-
toolbars: true,
1818
},
1919

2020
stories: [
@@ -32,7 +32,6 @@ const config: StorybookConfig = {
3232
addons: [
3333
'@storybook/addon-webpack5-compiler-swc',
3434
'@storybook/addon-docs',
35-
'@storybook/addon-a11y',
3635
'@storybook/addon-backgrounds',
3736
],
3837

@@ -55,8 +54,9 @@ const config: StorybookConfig = {
5554
// e.g process?.env?.SOME_VAR
5655
config.plugins?.push(
5756
new webpack.DefinePlugin({
58-
process: JSON.stringify({
59-
env: { SDC_URL: process.env.SDC_URL },
57+
'process.env': JSON.stringify({
58+
SDC_URL: process.env.SDC_URL,
59+
HOSTNAME: process.env.HOSTNAME ?? 'localhost',
6060
}),
6161
}),
6262
// We rely on Buffer for our bridget thrift client

dotcom-rendering/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
"lz-string": "1.5.0",
131131
"mockdate": "3.0.5",
132132
"node-fetch": "3.3.2",
133-
"path-browserify": "1.0.1",
134133
"postcss-styled-syntax": "0.6.3",
135134
"preact": "10.15.1",
136135
"preact-render-to-string": "6.0.2",

dotcom-rendering/src/lib/braze/forceBrazeMessage.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
const runtimeHostname = (): string | undefined => {
2-
if (typeof process !== 'undefined' && process.env.HOSTNAME) {
3-
return process.env.HOSTNAME;
4-
}
5-
if (typeof window !== 'undefined' && window.location.hostname) {
6-
return window.location.hostname;
7-
}
8-
return undefined;
9-
};
10-
111
const FORCE_BRAZE_ALLOWLIST = [
122
'preview.gutools.co.uk',
133
'preview.code.dev-gutools.co.uk',
14-
runtimeHostname(),
4+
process.env.HOSTNAME ?? 'localhost',
155
'm.thegulocal.com',
166
];
177

dotcom-rendering/src/lib/fonts-css.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,3 @@ export const rawFontsCss = fontList
265265
`,
266266
)
267267
.join('\n');
268-
269-
export const fontsCss = rawFontsCss;

dotcom-rendering/src/server/htmlPageTemplate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CleanCSS from 'clean-css';
44
import he from 'he';
55
import { ASSET_ORIGIN } from '../lib/assets';
66
import { escapeData } from '../lib/escapeData';
7-
import { fontsCss as rawFontsCss } from '../lib/fonts-css';
7+
import { rawFontsCss } from '../lib/fonts-css';
88
import type { Guardian } from '../model/guardian';
99
import type { Config } from '../types/configContext';
1010
import { GIT_COMMIT_HASH } from './prout';
@@ -57,6 +57,8 @@ const fontPreloadTags = fontFiles
5757
)
5858
.join('\n');
5959

60+
const minifiedFontsCss = new CleanCSS().minify(rawFontsCss).styles;
61+
6062
export const htmlPageTemplate = (props: WebProps | AppProps): string => {
6163
const {
6264
css,
@@ -392,7 +394,7 @@ https://workforus.theguardian.com/careers/product-engineering/
392394
: ''
393395
}
394396
${scriptTags.join('\n')}
395-
<style class="webfont">${new CleanCSS().minify(rawFontsCss).styles}</style>
397+
<style class="webfont">${minifiedFontsCss}</style>
396398
<style>${resets.resetCSS}</style>
397399
${css}
398400
<link rel="stylesheet" media="print" href="${ASSET_ORIGIN}static/frontend/css/print.css">

dotcom-rendering/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"webpack-env",
2525
"youtube",
2626
"twitter-for-web",
27+
// This is to fix a "Cannot find namespace 'Chai'" error that arose during
28+
// the upgrade to Storybook 9. Storybook uses vitest, which has chai as a
29+
// dependency, and this makes the chai types available globally.
2730
"chai"
2831
]
2932
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
},
2626
"dependencies": {
2727
"@guardian/prettier": "5.0.0",
28+
"@types/chai": "5.2.2",
2829
"chromatic": "13.3.0",
2930
"husky": "9.1.7",
3031
"lint-staged": "15.2.0",
3132
"prettier": "3.0.3",
32-
"tslib": "2.6.2",
33-
"@types/chai": "5.2.2"
33+
"tslib": "2.6.2"
3434
},
3535
"packageManager": "[email protected]",
3636
"pnpm": {

0 commit comments

Comments
 (0)