-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
75 lines (70 loc) · 1.69 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
66
67
68
69
70
71
72
73
74
75
import resolve from '@rollup/plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
import image from '@rollup/plugin-image';
import replace from 'rollup-plugin-replace';
import includePaths from 'rollup-plugin-includepaths';
import globals from 'rollup-plugin-node-globals';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import { terser } from 'rollup-plugin-terser';
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.scss', '.json'];
const CODES = [
'THIS_IS_UNDEFINED',
'MISSING_GLOBAL_NAME',
'CIRCULAR_DEPENDENCY',
];
const globalVars = {
react: 'React',
};
const discardWarning = warning => {
if (CODES.includes(warning.code)) {
return;
}
console.error(warning);
};
export default {
onwarn: discardWarning,
plugins: [
replace({
'process.node.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
peerDepsExternal(),
image(),
resolve({
jsnext: true,
extensions,
preferBuildins: true,
browser: true,
mainFields: ['browser', 'jsnext', 'module', 'main'],
}),
includePaths({
paths: ['src'],
extensions,
}),
commonjs({
include: 'node_modules/**',
}),
globals(),
json(),
postcss({
extract: false,
modules: true,
use: ['sass'],
}),
typescript({
rollupCommonJSResolveHack: false,
clean: true,
}),
terser(),
],
external: Object.keys(globalVars),
input: 'src/buildIndex.ts',
output: {
file: 'dist/index.js',
format: 'esm',
exports: 'named',
sourcemap: true,
},
};