1 | import pkg from './package.json'
|
2 | import resolve from '@rollup/plugin-node-resolve'
|
3 | import commonjs from '@rollup/plugin-commonjs'
|
4 | import babel from '@rollup/plugin-babel'
|
5 | import { terser } from 'rollup-plugin-terser'
|
6 | import replace from '@rollup/plugin-replace'
|
7 |
|
8 | function replaceStrings(isBrowser = true) {
|
9 | const isNode = !isBrowser
|
10 |
|
11 | return {
|
12 | 'process.browser': isBrowser.toString(),
|
13 | 'process.node': isNode.toString()
|
14 | }
|
15 | }
|
16 |
|
17 | export default [{
|
18 | input: 'src/index.js',
|
19 | output: [{
|
20 | file: pkg.main,
|
21 | format: 'cjs',
|
22 | sourcemap: true,
|
23 | exports: 'named'
|
24 | }],
|
25 | external: [
|
26 | ...Object.keys(pkg.dependencies || {})
|
27 | ],
|
28 | plugins: [
|
29 | replace(replaceStrings(false)),
|
30 | resolve({
|
31 | preferBuiltins: true
|
32 | }),
|
33 | commonjs()
|
34 | ]
|
35 | }, {
|
36 | input: 'src/index.js',
|
37 | output: [{
|
38 | file: pkg.module,
|
39 | format: 'es',
|
40 | sourcemap: true,
|
41 | }],
|
42 | external: [
|
43 | ...Object.keys(pkg.dependencies || {})
|
44 | ],
|
45 | plugins: [
|
46 | replace(replaceStrings(true)),
|
47 | resolve(),
|
48 | commonjs()
|
49 |
|
50 | ]
|
51 | }, {
|
52 | input: 'src/index.js',
|
53 | output: [{
|
54 | file: 'lib/index.js',
|
55 | format: 'umd',
|
56 | name: 'CSREST',
|
57 | exports: 'named',
|
58 | sourcemap: true,
|
59 | globals: { axios: 'axios' }
|
60 | }],
|
61 | external: ['axios'],
|
62 | plugins: [
|
63 | replace(replaceStrings(true)),
|
64 | resolve({ browser: true }),
|
65 | commonjs(),
|
66 | babel()
|
67 |
|
68 | ]
|
69 | }, {
|
70 | input: 'src/index.js',
|
71 | output: [{
|
72 | file: pkg.unpkg,
|
73 | format: 'umd',
|
74 | name: 'CSREST',
|
75 | exports: 'named',
|
76 | sourcemap: true,
|
77 | globals: { axios: 'axios' }
|
78 | }],
|
79 | external: ['axios'],
|
80 | plugins: [
|
81 | replace(replaceStrings(true)),
|
82 | resolve({ browser: true }),
|
83 | commonjs(),
|
84 | babel(),
|
85 | terser()
|
86 | ]
|
87 | }] |
\ | No newline at end of file |