forked from xyflow/xyflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.examples.js
58 lines (53 loc) · 1.58 KB
/
rollup.examples.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
import path from 'path';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import alias from '@rollup/plugin-alias';
import replace from '@rollup/plugin-replace';
import postcss from 'rollup-plugin-postcss';
import livereload from 'rollup-plugin-livereload';
import serve from 'rollup-plugin-serve';
import libraryRollupConfig from './rollup.config.js';
const isProd = process.env.NODE_ENV === 'production';
const isTesting = process.env.NODE_ENV === 'testing';
const serveFiles = !isProd || isTesting;
const doLiveReload = !isProd && !isTesting;
const rollupConfig = {
input: ['example/src/index.js'],
output: [
{
dir: 'example/public/dist',
format: 'iife',
sourcemap: !isProd,
},
],
plugins: [
replace({
'process.env.NODE_ENV': isProd ? JSON.stringify('production') : JSON.stringify('development'),
'process.env.FORCE_SIMILAR_INSTEAD_OF_MAP': 'false',
}),
postcss({
modules: false,
}),
alias({
entries: [{ find: 'react-flow-renderer', replacement: path.resolve(__dirname, 'dist', 'ReactFlow.esm.js') }],
}),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
}),
resolve(),
commonjs({
include: 'node_modules/**',
}),
serveFiles &&
serve({
open: true,
port: 3000,
contentBase: 'example/public/',
historyApiFallback: true,
}),
doLiveReload && livereload(),
],
};
export default isTesting ? rollupConfig : [libraryRollupConfig, rollupConfig];