-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrollup.sdk.config.js
93 lines (87 loc) · 1.91 KB
/
rollup.sdk.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
import { swc } from 'rollup-plugin-swc3';
import analyze from 'rollup-plugin-analyzer';
import renameNodeModules from 'rollup-plugin-rename-node-modules';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import { version } from './package.json';
const extensions = ['.js', '.ts'];
const isProduction = process.env.NODE_ENV === 'production';
const entry = 'src/index.ts';
const external = [
'crypto-js/enc-base64',
'crypto-js/sha256',
]
// Для отслеживания времени сборки
console.log('time:', new Date().getTime())
const plugins = [
resolve({
extensions,
browser: true,
}),
renameNodeModules('lib', false),
commonjs(),
replace({
exclude: 'node_modules/**',
values: {
'env.VERSION': JSON.stringify(version),
'env.PRODUCTION': isProduction,
},
preventAssignment: true,
}),
analyze( {
skipFormatted: true,
summaryOnly: true,
onAnalysis: (bundle) => {
// Для отслеживания времени и размеров сборки
console.log('size:', bundle.bundleSize);
console.log('time:', new Date().getTime());
} }),
];
const esm = {
input: {
index: entry,
},
external,
plugins: [
...plugins,
swc({ exclude: '', jsc: { target: "esnext" } }),
],
output: {
dir: 'dist-sdk/esm',
format: 'esm',
preserveModules: true,
preserveModulesRoot: 'src'
}
};
const cjs = {
input: {
index: entry,
},
external,
plugins: [
...plugins,
swc()
],
output: {
dir: 'dist-sdk/cjs',
format: 'cjs',
preserveModules: true,
preserveModulesRoot: 'src'
}
};
const umd = {
input: {
index: entry,
},
plugins: [
...plugins,
swc({ minify: true })
],
output: {
dir: 'dist-sdk/umd',
format: 'umd',
name: 'VKIDSDK',
}
}
export default [esm, cjs, umd];