diff options
author | 2024-04-08 16:20:58 +0200 | |
---|---|---|
committer | 2024-04-08 17:52:35 +0200 | |
commit | f862867a07fb09085a28bf134eb42276fde26540 (patch) | |
tree | b84f08003f0c143e27c3e3a339ab53f2aa339984 /subprojects/docs/src/plugins | |
parent | fix(language): Sonar lint issue (diff) | |
download | refinery-f862867a07fb09085a28bf134eb42276fde26540.tar.gz refinery-f862867a07fb09085a28bf134eb42276fde26540.tar.zst refinery-f862867a07fb09085a28bf134eb42276fde26540.zip |
docs: add Docusaurus website
Also refactor Yarn buildscripts.
Diffstat (limited to 'subprojects/docs/src/plugins')
-rw-r--r-- | subprojects/docs/src/plugins/swcMinifyPlugin.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/subprojects/docs/src/plugins/swcMinifyPlugin.ts b/subprojects/docs/src/plugins/swcMinifyPlugin.ts new file mode 100644 index 00000000..ecac654b --- /dev/null +++ b/subprojects/docs/src/plugins/swcMinifyPlugin.ts | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2024 The Refinery Authors | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | import type { Plugin } from '@docusaurus/types'; | ||
8 | import TerserPlugin from 'terser-webpack-plugin'; | ||
9 | |||
10 | /** | ||
11 | * A Docusarus plugin that replaces the built-in Javascript minifier with swc. | ||
12 | * | ||
13 | * See | ||
14 | * https://github.com/facebook/docusaurus/issues/4765#issuecomment-1679863984 | ||
15 | * but we use swc instead of esbuild. | ||
16 | * | ||
17 | * @returns The Docusarus plugin. | ||
18 | */ | ||
19 | export default function swcMinifyPlugin(): Plugin { | ||
20 | return { | ||
21 | name: 'refinery-swc-minify-plugin', | ||
22 | configureWebpack: (config) => ({ | ||
23 | mergeStrategy: { | ||
24 | 'optimization.minimizer': 'replace', | ||
25 | }, | ||
26 | optimization: { | ||
27 | minimizer: | ||
28 | config.optimization?.minimizer?.map((plugin) => { | ||
29 | // `instanceof` seems to be broken, because a different version of | ||
30 | // `TerserPlguin` is coming from Docusaurus than the one we import. | ||
31 | if (plugin?.constructor.name === TerserPlugin.name) { | ||
32 | return new TerserPlugin({ | ||
33 | minify: TerserPlugin.swcMinify, | ||
34 | }); | ||
35 | } | ||
36 | return plugin; | ||
37 | }) ?? [], | ||
38 | }, | ||
39 | }), | ||
40 | }; | ||
41 | } | ||