This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
96 lines (93 loc) · 2.37 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
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
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 nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import autoprefixer from 'autoprefixer';
import cssimport from 'postcss-import';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import tailwindcss from 'tailwindcss';
import pkg from './package.json' assert { type: 'json' };
const extensions = ['.mjs', '.js', '.jsx', '.ts', '.tsx'];
const config = [
{
input: 'index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
exports: 'named',
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
exports: 'named',
},
],
external: [/@babel\/runtime/, 'react', 'react-dom'],
plugins: [
babel({
babelHelpers: 'runtime',
presets: [
'@babel/preset-env',
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-transform-runtime',
[
'prismjs', {
'languages': 'all',
'plugins': ['autoloader'],
},
],
],
extensions: extensions,
include: ['src/**/*'],
exclude: 'node_modules/**',
}),
commonjs({
include: 'node_modules/**',
extensions: extensions,
}),
image(),
json({
compact: true,
}),
peerDepsExternal(),
postcss({
config: {
path: './postcss.config.mjs',
},
extensions: ['.css'],
minimize: true,
extract: true,
plugins: [cssimport(), autoprefixer(), tailwindcss()],
}),
terser(),
typescript({
tsconfig: './tsconfig.json',
outputToFilesystem: false,
compilerOptions: {
declaration: true,
declarationDir: 'dist',
},
exclude: ['node_modules', '**/*.stories.tsx'],
}),
nodeResolve({
extensions: extensions,
}),
],
},
];
export default config;