-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.mjs
83 lines (77 loc) · 1.85 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
import { exec } from 'child_process';
import { babel } from '@rollup/plugin-babel';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json' assert { type: 'json' };
function tscAliasPlugin() {
return {
name: 'tsc-alias',
writeBundle: () => {
return new Promise((resolve, reject) => {
exec('tsc-alias', function callback(error, stdout, stderr) {
if (stderr || error) {
reject(stderr || error);
} else {
resolve(stdout);
}
});
});
},
};
}
/** @type {import('rollup').RollupOptions} */
const buildConfig = {
input: 'src/index.ts',
output: [
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
nodeResolve(),
commonjs({
transformMixedEsModules: true
}),
babel({
exclude: 'node_modules/**',
presets: ['@babel/preset-env', '@babel/preset-react'],
}),
tscAliasPlugin(),
json(),
typescript({ sourceMap: true }),
postcss({
extract: true,
modules: {
exportGlobals: true,
generateScopedName: '[local]_[hash:base64:5]',
},
use: ['sass'],
}),
],
};
/** @type {import('rollup').RollupOptions} */
const browserConfig = {
input: 'dist/index.js',
output: [
{
file: pkg.unpkg,
format: 'umd',
name: '@appello/web-ui',
},
],
plugins: [terser()],
};
export default [buildConfig, browserConfig];