forked from WalletConnect/modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
58 lines (51 loc) · 1.44 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
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import esbuild from 'rollup-plugin-esbuild'
import litCss from 'rollup-plugin-lit-css'
import minifyHtml from 'rollup-plugin-minify-html-literals'
import nodePolyfill from 'rollup-plugin-polyfill-node'
export default function createConfig(packageJson, isBundle = false) {
const esbuildPluginEs = esbuild({
minify: true,
tsconfig: 'tsconfig.json',
platform: 'browser',
treeShaking: true,
loaders: {
'.json': 'json'
}
})
const litCssPlugin = litCss({
include: ['**/*.css'],
uglify: true
})
const replacePlugin = replace({
'process.env.ROLLUP_WCM_VERSION': JSON.stringify(packageJson.version)
})
const plugnsCommon = [replacePlugin, litCssPlugin, minifyHtml.default()]
const pluginsEs = [...plugnsCommon, esbuildPluginEs]
const pluginsUmd = [
...plugnsCommon,
esbuildPluginEs,
nodeResolve({ browser: true }),
commonjs(),
json(),
nodePolyfill()
]
const config = [
{
input: './index.ts',
plugins: pluginsEs,
output: [{ file: './dist/index.js', format: 'es', sourcemap: true }]
}
]
if (isBundle) {
config.push({
input: './bundle.ts',
plugins: pluginsUmd,
output: [{ dir: './dist/cdn', format: 'es', sourcemap: true }]
})
}
return config
}