-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
/
index.ts
51 lines (46 loc) · 1.47 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {LoadContext} from '@docusaurus/types';
import {PluginOptions} from './types';
import {Configuration} from 'webpack';
import path from 'path';
export default function (_context: LoadContext, options: PluginOptions) {
const isProd = process.env.NODE_ENV === 'production';
return {
name: 'docusaurus-plugin-ideal-image',
getThemePath() {
return path.resolve(__dirname, './theme');
},
configureWebpack(_config: Configuration, isServer: boolean) {
return {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
use: [
'@docusaurus/lqip-loader',
{
loader: '@endiliey/responsive-loader',
options: {
emitFile: !isServer, // don't emit for server-side rendering
disable: !isProd,
// eslint-disable-next-line
adapter: require('@endiliey/responsive-loader/sharp'),
name: isProd
? 'ideal-img/[name].[hash:hex:7].[width].[ext]'
: 'ideal-img/[name].[width].[ext]',
...options,
},
},
],
},
],
},
};
},
};
}