-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
81 lines (75 loc) · 2.85 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
76
77
78
79
80
81
import resolveNode from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
import externalGlobals from 'rollup-plugin-external-globals';
import babel from '@rollup/plugin-babel';
import filesize from 'rollup-plugin-filesize';
import visualizer from 'rollup-plugin-visualizer';
const tsOpts = {
target: 'es2018',
strict: true,
noImplicitReturns: true,
esModuleInterop: true,
jsx: 'preserve',
include: ['src/**/*'],
exclude: ['node_modules', '**/*.test.ts', 'src/factories/*', 'src/cdk/*'],
tsconfig: false,
};
const globals = {
react: 'guardian.automat.preact',
'@emotion/core': 'guardian.automat.emotionCore',
};
const config = [
['epic', 'src/components/modules/epics/ContributionsEpic.tsx', 'dist/modules/epics/Epic.js'],
[
'aus-banner',
'src/components/modules/banners/ausMomentContributionsBanner/AusMomentContributionsBanner.tsx',
'dist/modules/banners/ausMomentContributionsBanner/AusMomentContributionsBanner.js',
],
[
'aus-thank-you-banner',
'src/components/modules/banners/ausMomentThankYouBanner/AusMomentThankYouBanner.tsx',
'dist/modules/banners/ausMomentThankYouBanner/AusMomentThankYouBanner.js',
],
[
'digital-subscriptions-banner',
'src/components/modules/banners/digitalSubscriptions/DigitalSubscriptionsBanner.tsx',
'dist/modules/banners/digitalSubscriptions/DigitalSubscriptionsBanner.js',
],
[
'guardian-weekly-banner',
'src/components/modules/banners/guardianWeekly/GuardianWeeklyBanner.tsx',
'dist/modules/banners/guardianWeekly/GuardianWeeklyBanner.js',
],
].map(([name, entryPoint, target]) => {
const isProd = process.env.NODE_ENV === 'production';
return {
input: entryPoint,
output: {
file: target,
format: 'es',
sourcemap: isProd ? false : 'inline',
},
external: id => Object.keys(globals).some(key => id == key),
plugins: [
resolveNode(),
commonjs(),
json(),
typescript(tsOpts),
babel({
extensions: ['.ts', '.tsx', '.js', '.jsx', '.es6', '.es', '.mjs'],
babelHelpers: 'bundled',
}),
// eslint-disable-next-line @typescript-eslint/camelcase
terser({ compress: { global_defs: { 'process.env.NODE_ENV': 'production' } } }),
externalGlobals(globals),
filesize(),
// Note, visualizer is useful for *relative* sizes, but reports
// pre-minification.
visualizer({ sourcemap: !isProd, gzipSize: true, filename: `stats/${name}.html` }),
],
};
});
export default config;