-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.prod.js
71 lines (69 loc) · 2.29 KB
/
rollup.config.prod.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
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import postcss from 'rollup-plugin-postcss';
import babel from '@rollup/plugin-babel';
import bundleScss from 'rollup-plugin-bundle-scss';
import copy from 'rollup-plugin-copy-assets';
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
import getFiles from './src/utils/getFiles/getFiles';
import pkg from './package.json';
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
const excludedExtensions = ['.stories.js', '.stories.tsx', '.test.js', '.test.tsx'];
export default {
input: [
'src/index.js',
...getFiles('src/accelerator', extensions, excludedExtensions),
...getFiles('src/components', extensions, excludedExtensions),
...getFiles('src/constants', extensions, excludedExtensions),
...getFiles('src/elements', extensions, excludedExtensions),
...getFiles('src/unreleased', extensions, excludedExtensions),
...getFiles('src/hooks', extensions, excludedExtensions),
...getFiles('src/utils', extensions, excludedExtensions),
...getFiles('src/user', extensions, excludedExtensions),
...getFiles('__mocks__', extensions, excludedExtensions),
...getFiles('__customQueries__', extensions, excludedExtensions),
],
output: [
{
dir: 'build',
format: 'cjs',
preserveModules: true,
preserveModulesRoot: 'src',
sourcemap: true,
},
],
external: [
...Object.keys(pkg.devDependencies),
...Object.keys(pkg.dependencies),
/@babel\/runtime/,
],
plugins: [
peerDepsExternal(),
resolve({ extensions }),
babel({
exclude: ['node_modules/**'],
babelHelpers: 'runtime',
extensions,
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-react-jsx',
],
}),
typescript(),
commonjs(),
json(),
copy({
assets: ['src/assets/icons', 'src/assets/sass'],
}),
postcss({
plugins: [],
}),
bundleScss(),
terser({ keep_fnames: true }),
],
};