-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
50 lines (47 loc) · 1.36 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
import babel from '@rollup/plugin-babel';
import eslint from '@rollup/plugin-eslint';
import livereload from 'rollup-plugin-livereload';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import serve from 'rollup-plugin-serve';
const { ENVIRONMENT } = process.env;
const isDevelopment = ENVIRONMENT === 'development';
const isProduction = ENVIRONMENT === 'production';
const isTesting = ENVIRONMENT === 'testing';
const isDevelopmentOrTesting = isDevelopment || isTesting;
const esFormat = {
file: 'dist/Dropout.js',
format: 'es',
};
const iifeFormat = {
file: 'dist/Dropout.js',
format: 'iife',
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
name: 'Dropout',
};
export default {
input: 'src/index.js',
output: [
isProduction && esFormat,
isDevelopmentOrTesting && iifeFormat,
].filter((x) => x),
// All the used libs needs to be here
external: ['react', 'prop-types'],
plugins: [
eslint({
throwOnError: isProduction,
throwOnWarning: isProduction,
}),
isDevelopmentOrTesting &&
serve({
contentBase: ['dist', 'demo', 'node_modules/@babel/standalone'],
historyApiFallback: true,
port: 3000,
}),
isDevelopment && livereload({ watch: ['dist', 'demo'] }),
nodeResolve(),
babel({ babelHelpers: 'runtime', exclude: 'node_modules/**' }),
].filter((x) => x),
};