-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
65 lines (61 loc) · 1.59 KB
/
rollup.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
import excludeDependenciesFromBundle from 'rollup-plugin-exclude-dependencies-from-bundle';
import postcss from 'rollup-plugin-postcss'
import {nodeResolve} from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import * as fs from 'fs';
import path from 'path';
const PACKAGE_NAME = process.cwd();
const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_NAME, 'package.json'), 'utf-8'));
const commonjsOptions = {
ignoreGlobal: true,
include: /node_modules/,
}
const extensions = ['.js', '.ts', '.tsx'];
const babelOptions = {
exclude: /node_modules/,
extensions,
configFile: '../../babel.config.json',
babelHelpers: 'runtime'
};
const nodeOptions = {
extensions,
};
const typescriptOptions = {
tsconfig: `${PACKAGE_NAME}/tsconfig.json`,
declaration: true,
declarationDir: '.',
emitDeclarationOnly: true,
declarationMap: true,
};
export default {
input: `${PACKAGE_NAME}/src/index.ts`,
external: [...Object.keys(pkg.peerDependencies), '@emotion/cache'],
output: [
{
file: pkg.main,
format: 'cjs'
},
{
file: pkg.module,
format: 'es'
}
],
plugins: [
nodeResolve(nodeOptions),
typescript(typescriptOptions),
postcss({
plugins: []
}),
excludeDependenciesFromBundle({peerDependencies: true}),
babel(babelOptions),
commonjs(commonjsOptions),
terser(),
// visualizer({
// filename: 'bundle-analysis.html',
// open: true,
// }),
]
}