forked from subquery/subquery-component-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
104 lines (98 loc) · 2.76 KB
/
rollup.config.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable @typescript-eslint/no-var-requires */
// use require for storybook compatible, some library in yarn.lock only have cjs version of low version.
// if upgrade them may cause storybook crush.
// TODO: use other lightweight document replace storybook
const path = require('node:path');
const typescript = require('@rollup/plugin-typescript');
const svg = require('rollup-plugin-svg');
const { terser } = require('rollup-plugin-terser');
const postcss = require('rollup-plugin-postcss');
const copy = require('rollup-plugin-copy');
const outputOptions = {
// TODO arrange them.
globals: {
react: 'react',
antd: 'antd',
'react-dom': 'react-dom',
'react-router-dom': 'react-router-dom',
'react/jsx-runtime': 'react/jsx-runtime',
'@ant-design/icons': '@ant-design/icons',
clsx: 'clsx',
graphiql: 'graphiql',
'@graphiql/toolkit': '@graphiql/toolkit',
'use-screen': 'use-screen',
'react-icons/ai': 'react-icons/ai',
'react-icons/io5': 'react-icons/io5',
'react-jazzicon': 'react-jazzicon',
'react-icons/bs': 'react-icons/bs',
'antd/es/card/Meta': 'antd/es/card/Meta',
'antd/dist/reset.css': 'antd/dist/reset.css',
'graphiql/graphiql.min.css': 'graphiql/graphiql.min.css',
},
};
const resolvePath = (str) => path.resolve(__dirname, str);
export default {
input: {
'subquery-components.es': path.resolve('components/index.ts'),
'common/GraphiQL/index': path.resolve('components/common/GraphiQL/index.ts'),
},
external: [
'react',
'react-dom',
'antd',
'node_modules/*',
'react-router-dom',
'react/jsx-runtime',
'clsx',
'graphiql',
/^@graphiql\/.*/,
'use-screen',
'react-icons/ai',
'react-icons/io5',
'react-jazzicon',
'antd/es/card/Meta',
'react-icons/bs',
'antd/dist/reset.css',
'graphiql/graphiql.min.css',
/^@ant-design\/icons\/.*/,
],
output: [
{
...outputOptions,
format: 'es',
name: 'esm',
// file: 'dist/subquery-components.es.js',
dir: 'dist',
},
],
plugins: [
typescript({
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
rootDir: resolvePath('components/'),
declaration: true,
declarationDir: resolvePath('dist'),
exclude: [resolvePath('assets/**'), resolvePath('node_modules/**')],
allowSyntheticDefaultImports: true,
}),
postcss({
minimize: true,
modules: false,
use: {
less: { javascriptEnabled: true },
},
extract: 'subquery-components.css',
}),
svg(),
terser(),
copy({
targets: [
{
src: 'components/assets',
dest: 'dist',
},
],
}),
],
};