-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
105 lines (98 loc) · 2.52 KB
/
Copy pathrollup.config.mjs
File metadata and controls
105 lines (98 loc) · 2.52 KB
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
105
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import image from '@rollup/plugin-image'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import typescript from '@rollup/plugin-typescript'
import { createRequire } from 'node:module'
import del from 'rollup-plugin-delete'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import postcss from 'rollup-plugin-postcss'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')
const dependencyNames = new Set([
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
])
const buildSourceMap = process.env.BUILD_SOURCEMAP !== 'false'
const isExternal = (id) => {
if (id.startsWith('.') || id.startsWith('/')) {
return false
}
for (const dep of dependencyNames) {
if (id === dep || id.startsWith(`${dep}/`)) {
return true
}
}
return false
}
export default [
{
input: {
index: 'src/index.ts',
admin: 'src/entries/admin.ts',
utils: 'src/entries/utils.ts',
hooks: 'src/entries/hooks.ts'
},
output: [
{
dir: 'dist',
format: 'cjs',
sourcemap: buildSourceMap,
entryFileNames: 'cjs/[name].js',
chunkFileNames: 'cjs/chunks/[name]-[hash].js',
exports: 'named'
},
{
dir: 'dist',
format: 'esm',
sourcemap: buildSourceMap,
entryFileNames: 'esm/[name].js',
chunkFileNames: 'esm/chunks/[name]-[hash].js'
}
],
external: isExternal,
plugins: [
del({ targets: 'dist/*' }),
peerDepsExternal(),
resolve({
extensions: ['.ts', '.tsx', '.js', '.jsx'],
preferBuiltins: false
}),
commonjs(),
json(),
image(),
postcss({
extract: false,
minimize: true,
inject: true,
use: {
sass: {
silenceDeprecations: ['legacy-js-api']
}
}
}),
typescript({
tsconfig: './tsconfig.json',
sourceMap: buildSourceMap,
inlineSources: buildSourceMap
}),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx']
}),
terser({
maxWorkers: 1,
compress: {
drop_console: ['log', 'info'],
drop_debugger: true
},
output: {
comments: false
}
})
]
}
]