1 | import babel from 'rollup-plugin-babel';
|
2 | import commonjs from 'rollup-plugin-commonjs';
|
3 | import replace from 'rollup-plugin-replace';
|
4 | import resolve from 'rollup-plugin-node-resolve';
|
5 | import {uglify} from 'rollup-plugin-uglify';
|
6 |
|
7 | import pkg from './package.json';
|
8 |
|
9 | function distBuild(options) {
|
10 | options = options || {};
|
11 |
|
12 | return {
|
13 | input: 'src/index.js',
|
14 | output: {
|
15 | file: `dist/${options.filename}`,
|
16 | format: options.format,
|
17 | name: 'aphrodite',
|
18 | sourcemap: options.sourcemap,
|
19 | },
|
20 | plugins: [
|
21 | babel({
|
22 | exclude: ['node_modules/**'],
|
23 | }),
|
24 | replace({
|
25 | 'process.env.NODE_ENV': JSON.stringify('production'),
|
26 | }),
|
27 | resolve({
|
28 | browser: true,
|
29 | }),
|
30 | commonjs(),
|
31 | options.minify && uglify(),
|
32 | ]
|
33 | };
|
34 | }
|
35 |
|
36 | const externals = new Set(Object.keys(pkg.dependencies));
|
37 | externals.delete('inline-style-prefixer');
|
38 |
|
39 | function standardBuilds() {
|
40 | return {
|
41 | input: ['src/index.js', 'src/no-important.js'],
|
42 | external: (id /*: string */) => {
|
43 | if (externals.has(id)) {
|
44 | return true;
|
45 | }
|
46 | },
|
47 | output: [
|
48 | { dir: 'lib', format: 'cjs' },
|
49 | { dir: 'es', format: 'es' },
|
50 | ],
|
51 | plugins: [
|
52 | babel({
|
53 | exclude: ['node_modules/**'],
|
54 | }),
|
55 | resolve({
|
56 | browser: true,
|
57 | }),
|
58 | commonjs(),
|
59 | ],
|
60 | };
|
61 | }
|
62 |
|
63 | export default [
|
64 | distBuild({ filename: 'aphrodite.umd.js', format: 'umd', sourcemap: true, minify: false }),
|
65 | distBuild({ filename: 'aphrodite.umd.min.js', format: 'umd', sourcemap: true, minify: true }),
|
66 | distBuild({ filename: 'aphrodite.js', format: 'cjs', sourcemap: false, minify: false }),
|
67 | standardBuilds(),
|
68 | ];
|