|
1 | | -import { nodeResolve } from '@rollup/plugin-node-resolve'; |
2 | | -import replace from '@rollup/plugin-replace'; |
3 | | -import commonjs from '@rollup/plugin-commonjs'; |
4 | | -import { babel } from '@rollup/plugin-babel'; |
5 | | -import { terser } from 'rollup-plugin-terser'; |
6 | | -import filesize from 'rollup-plugin-filesize'; |
| 1 | +import { nodeResolve } from "@rollup/plugin-node-resolve"; |
| 2 | +import replace from "@rollup/plugin-replace"; |
| 3 | +import commonjs from "@rollup/plugin-commonjs"; |
| 4 | +import { babel } from "@rollup/plugin-babel"; |
| 5 | +import { terser } from "rollup-plugin-terser"; |
| 6 | +import filesize from "rollup-plugin-filesize"; |
7 | 7 |
|
8 | 8 | const plugins = [ |
9 | 9 | nodeResolve({ |
10 | 10 | jsnext: true, |
11 | | - modulesOnly: true |
| 11 | + modulesOnly: true, |
12 | 12 | }), |
13 | 13 | commonjs({ |
14 | | - include: 'node_modules/**', |
| 14 | + include: "node_modules/**", |
15 | 15 | }), |
16 | 16 | babel({ |
17 | | - babelHelpers: 'runtime', |
| 17 | + babelHelpers: "runtime", |
18 | 18 | babelrc: false, |
19 | 19 | presets: [ |
20 | | - ['@babel/preset-env', { modules: false, loose: true }], |
21 | | - '@babel/preset-react', |
| 20 | + ["@babel/preset-env", { modules: false, loose: true }], |
| 21 | + "@babel/preset-react", |
22 | 22 | ], |
23 | 23 | plugins: [ |
24 | | - '@babel/plugin-transform-runtime', |
25 | | - '@babel/plugin-proposal-object-rest-spread', |
26 | | - '@babel/plugin-proposal-class-properties', |
27 | | - '@babel/plugin-proposal-private-property-in-object', |
28 | | - '@babel/plugin-proposal-private-methods', |
29 | | - 'transform-react-remove-prop-types', |
30 | | - ].filter(Boolean) |
31 | | - }) |
| 24 | + "@babel/plugin-transform-runtime", |
| 25 | + "@babel/plugin-proposal-object-rest-spread", |
| 26 | + "@babel/plugin-proposal-class-properties", |
| 27 | + "@babel/plugin-proposal-private-property-in-object", |
| 28 | + "@babel/plugin-proposal-private-methods", |
| 29 | + "transform-react-remove-prop-types", |
| 30 | + ].filter(Boolean), |
| 31 | + }), |
32 | 32 | ]; |
33 | 33 |
|
34 | 34 | const devPlugins = plugins.concat([ |
35 | 35 | replace({ |
36 | | - 'process.env.NODE_ENV': JSON.stringify('development'), |
| 36 | + "process.env.NODE_ENV": JSON.stringify("development"), |
37 | 37 | preventAssignment: true, |
38 | | - }) |
| 38 | + }), |
39 | 39 | ]); |
40 | 40 |
|
41 | 41 | const prodPlugins = plugins.concat([ |
42 | 42 | replace({ |
43 | | - 'process.env.NODE_ENV': JSON.stringify('production'), |
| 43 | + "process.env.NODE_ENV": JSON.stringify("production"), |
44 | 44 | preventAssignment: true, |
45 | 45 | }), |
46 | 46 | terser(), |
47 | | - filesize() |
| 47 | + filesize(), |
48 | 48 | ]); |
49 | 49 |
|
50 | 50 | const base = { |
51 | | - input: 'src/index.js', |
52 | | - external: ['react', 'react-dom', 'prism-react-renderer', 'buble'] |
| 51 | + input: "src/index.js", |
| 52 | + external: ["react", "react-dom", "prism-react-renderer", "buble"], |
53 | 53 | }; |
54 | 54 |
|
55 | 55 | const output = { |
56 | | - exports: 'named', |
| 56 | + exports: "named", |
57 | 57 | globals: { |
58 | | - 'prism-react-renderer': 'Prism', |
59 | | - react: 'React', |
60 | | - buble: 'Buble', |
61 | | - 'react-dom': 'ReactDOM' |
62 | | - } |
| 58 | + "prism-react-renderer": "Prism", |
| 59 | + react: "React", |
| 60 | + buble: "Buble", |
| 61 | + "react-dom": "ReactDOM", |
| 62 | + }, |
63 | 63 | }; |
64 | 64 |
|
65 | | -const makeOutput = config => Object.assign({}, output, config); |
| 65 | +const makeOutput = (config) => Object.assign({}, output, config); |
66 | 66 |
|
67 | | -const withBase = config => Object.assign({}, base, config); |
| 67 | +const withBase = (config) => Object.assign({}, base, config); |
68 | 68 |
|
69 | 69 | export default [ |
70 | 70 | { |
71 | 71 | output: [ |
72 | 72 | { |
73 | | - name: 'ReactLive', |
74 | | - file: 'dist/react-live.min.js', |
75 | | - format: 'umd' |
76 | | - } |
| 73 | + name: "ReactLive", |
| 74 | + file: "dist/react-live.min.js", |
| 75 | + format: "umd", |
| 76 | + }, |
77 | 77 | ].map(makeOutput), |
78 | | - plugins: prodPlugins |
| 78 | + plugins: prodPlugins, |
79 | 79 | }, |
80 | 80 | { |
81 | 81 | output: [ |
82 | 82 | { |
83 | | - name: 'ReactLive', |
84 | | - file: 'dist/react-live.js', |
85 | | - format: 'umd' |
| 83 | + name: "ReactLive", |
| 84 | + file: "dist/react-live.js", |
| 85 | + format: "umd", |
86 | 86 | }, |
87 | 87 | { |
88 | | - file: 'dist/react-live.es.js', |
89 | | - format: 'es' |
| 88 | + file: "dist/react-live.es.js", |
| 89 | + format: "es", |
90 | 90 | }, |
91 | 91 | { |
92 | | - file: 'dist/react-live.cjs.js', |
93 | | - format: 'cjs' |
94 | | - } |
| 92 | + file: "dist/react-live.cjs.js", |
| 93 | + format: "cjs", |
| 94 | + }, |
95 | 95 | ].map(makeOutput), |
96 | | - plugins: devPlugins |
97 | | - } |
| 96 | + plugins: devPlugins, |
| 97 | + }, |
98 | 98 | ].map(withBase); |
0 commit comments