aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/responsiveLoaderPlugin.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-03-17 19:47:53 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2024-03-17 20:15:57 +0100
commit219c362b21608a9bb763ee310b1125a50aa1a312 (patch)
tree813a39325b8192b48d8ece1598ca38a04cb141ce /src/plugins/responsiveLoaderPlugin.ts
parentFix research topic spacing on mobile (diff)
downloadblog-219c362b21608a9bb763ee310b1125a50aa1a312.tar.gz
blog-219c362b21608a9bb763ee310b1125a50aa1a312.tar.zst
blog-219c362b21608a9bb763ee310b1125a50aa1a312.zip
Add contacts section
Also enables responsive image optimization
Diffstat (limited to 'src/plugins/responsiveLoaderPlugin.ts')
-rw-r--r--src/plugins/responsiveLoaderPlugin.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/plugins/responsiveLoaderPlugin.ts b/src/plugins/responsiveLoaderPlugin.ts
new file mode 100644
index 0000000..3dc198e
--- /dev/null
+++ b/src/plugins/responsiveLoaderPlugin.ts
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) 2016, Jeremy Stucki
3 * Copyright (c) 2024 Kristóf Marussy <kristof@marussy.com>
4 *
5 * SPDX-License-Identifier: MIT AND BSD-3-Clause
6 */
7
8import type { Plugin } from '@docusaurus/types';
9import sharp from 'responsive-loader/sharp';
10
11export default function responsiveLoaderPlugin(): Plugin {
12 return {
13 name: 'marussy-responsive-loader-plugin',
14 configureWebpack: () => ({
15 mergeStrategy: {
16 'module.rules': 'prepend',
17 },
18 // Configuration based on
19 // https://github.com/dazuaz/responsive-loader/blob/ef2c806fcd36f06f6be8a0b97e09f40c3d86d3ac/README.md
20 module: {
21 rules: [
22 {
23 test: /\.(png|jpe?g)$/,
24 use: [
25 {
26 loader: 'responsive-loader',
27 options: {
28 adapter: sharp,
29 format: 'webp',
30 },
31 },
32 ],
33 type: 'javascript/auto',
34 },
35 ],
36 },
37 }),
38 };
39}