This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
80 lines (73 loc) · 1.8 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
import fs from 'fs';
import path from 'path';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import { terser } from "rollup-plugin-terser";
import visualizer from 'rollup-plugin-visualizer';
import replace from '@rollup/plugin-replace';
const prod = process.env.NODE_ENV === 'production';
const mode = prod ? 'production' : 'development';
console.log(`Creating ${mode} bundle...`);
const babelrc = JSON.parse(fs.readFileSync(path.join(__dirname, './.babelrc')));
const plugins = [
babel(
Object.assign({}, babelrc, {
babelrc: false,
exclude: 'node_modules/**',
presets: ['@babel/react'],
plugins: babelrc.plugins.concat(['@babel/plugin-external-helpers'])
})
),
nodeResolve({
jsnext: true
}),
commonjs({
// exclude: ['node_modules/**']
namedExports: {
'node_modules/prop-types/index.js': ['PropTypes']
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
})
];
if (prod)
plugins.push(terser(), visualizer({ filename: './bundle-stats.html' }));
const input = 'src/index.js';
const outputName = 'screenfull-react';
const external = ['react', 'react-dom'];
const globals = {
react: 'React',
'react-dom': 'ReactDOM'
};
export default {
input,
output: [
{
name: outputName,
file: 'dist/screenfull-react.js',
format: 'cjs',
globals,
sourcemap: true,
exports: 'named'
},
{
name: outputName,
file: 'dist/screenfull-react.umd.js',
format: 'umd',
globals,
exports: 'named'
},
{
name: outputName,
file: 'dist/screenfull-react.es.js',
format: 'es',
globals,
sourcemap: true,
exports: 'named'
}
],
external,
plugins
};