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