-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathrollup.config.mjs
61 lines (56 loc) · 1.54 KB
/
rollup.config.mjs
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
import { createRequire } from 'node:module'
import alias from '@rollup/plugin-alias'
import url from '@rollup/plugin-url'
import svgr from '@svgr/rollup'
import json from 'rollup-plugin-json'
import postcss from 'rollup-plugin-postcss'
import rollupTypescript from 'rollup-plugin-typescript2'
import pkg from './package.json' assert { type: 'json' }
const cjsRequire = createRequire(import.meta.url)
const tspCompiler = cjsRequire('ts-patch/compiler')
const external = [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.devDependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {}),
'@emotion/react/jsx-runtime',
'@emotion/cache',
'@emotion/is-prop-valid',
'@emotion/css',
'bn.js'
]
export default {
input: 'src/index.ts',
output: [
{
dir: 'dist',
format: 'es',
exports: 'named',
sourcemap: true,
preserveModules: true
}
],
plugins: [
json(),
alias({
// Properly resolve json files from assets folder
entries: [{ find: /^assets\/(.*)/, replacement: 'src/assets/$1' }]
}),
postcss({
minimize: true,
extract: 'harmony.css',
modules: true
}),
svgr(),
rollupTypescript({
typescript: tspCompiler,
clean: true
}),
url({
include: ['**/*.png', '**/*.jpg'], // Specify file extensions to handle
limit: 8192, // Inline files smaller than 8kb as base64 URLs
emitFiles: true, // Copy larger files to the output directory
fileName: '[name][extname]' // Customize the output file name
})
],
external
}