1 | import path from 'path'
|
2 | import resolve from '@rollup/plugin-node-resolve'
|
3 | import commonjs from '@rollup/plugin-commonjs'
|
4 | import replace from '@rollup/plugin-replace'
|
5 | import { terser } from 'rollup-plugin-terser'
|
6 |
|
7 | const input = path.resolve(__dirname, 'dist/esm/index.js')
|
8 | function replaceNodeEnv(env) {
|
9 | return replace({
|
10 | values: { 'process.env.NODE_ENV': JSON.stringify(env) },
|
11 | delimiters: ['', ''],
|
12 | })
|
13 | }
|
14 | const commonPlugins = [resolve({ browser: true }), commonjs()]
|
15 | const external = ['react', 'react-dom', 'react-dnd']
|
16 | const globals = {
|
17 | react: 'React',
|
18 | 'react-dom': 'ReactDOM',
|
19 | 'react-dnd': 'ReactDnD',
|
20 | }
|
21 |
|
22 | export default [
|
23 | {
|
24 | input,
|
25 | external,
|
26 | plugins: [...commonPlugins, replaceNodeEnv('development')],
|
27 | output: [
|
28 | {
|
29 | name: 'ReactDnDHTML5Backend',
|
30 | file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.js'),
|
31 | format: 'umd',
|
32 | globals,
|
33 | },
|
34 | ],
|
35 | },
|
36 | {
|
37 | input,
|
38 | external,
|
39 | plugins: [...commonPlugins, replaceNodeEnv('production'), terser()],
|
40 | output: [
|
41 | {
|
42 | name: 'ReactDnDHTML5Backend',
|
43 | file: path.resolve(__dirname, 'dist/umd/ReactDnDHTML5Backend.min.js'),
|
44 | format: 'umd',
|
45 | globals,
|
46 | },
|
47 | ],
|
48 | },
|
49 | ]
|