forked from Khan/aphrodite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
68 lines (62 loc) · 2.05 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
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
import pkg from './package.json';
function distBuild(options) {
options = options || {};
return {
input: 'src/index.js',
output: {
file: `dist/${options.filename}`,
format: options.format,
name: 'aphrodite',
sourcemap: options.sourcemap,
},
plugins: [
babel({
exclude: ['node_modules/**'],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
resolve({
browser: true,
}), // so rollup can find node modules
commonjs(), // so rollup can convert node modules to ESM if needed
options.minify && uglify(),
]
};
}
const externals = new Set(Object.keys(pkg.dependencies));
externals.delete('inline-style-prefixer');
function standardBuilds() {
return {
input: ['src/index.js', 'src/no-important.js', 'src/exports.js'],
external: (id /*: string */) => {
if (externals.has(id)) {
return true;
}
},
output: [
{ dir: 'lib', format: 'cjs' },
{ dir: 'es', format: 'es' },
],
plugins: [
babel({
exclude: ['node_modules/**'],
}),
resolve({
browser: true,
}), // so rollup can find node modules
commonjs(), // so rollup can convert node modules to ESM if needed
],
};
}
export default [
distBuild({ filename: 'aphrodite.umd.js', format: 'umd', sourcemap: true, minify: false }),
distBuild({ filename: 'aphrodite.umd.min.js', format: 'umd', sourcemap: true, minify: true }),
distBuild({ filename: 'aphrodite.js', format: 'cjs', sourcemap: false, minify: false }),
standardBuilds(),
];