forked from react-component/m-pull-to-refresh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
65 lines (64 loc) · 1.73 KB
/
rollup.config.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
59
60
61
62
63
64
65
const resolve = require('@rollup/plugin-node-resolve').default;
const commonjs = require('@rollup/plugin-commonjs');
const typescript = require('rollup-plugin-typescript2');
const jsx = require('acorn-jsx');
const dts = require('rollup-plugin-dts').default;
const path = require('path');
const babelPlugin = require('@rollup/plugin-babel');
const { babel, getBabelOutputPlugin } = babelPlugin;
const config = {
input: 'src/index.tsx',
external: ['react', 'classnames'],
}
export default [
{
...config,
acornInjectPlugins: [jsx()],
plugins: [
resolve(),
commonjs(),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'bundled'
}),
typescript({
tsconfig: path.resolve(__dirname, './tsconfig.json'),
tsconfigOverride: {
compilerOptions: {
declaration: false,
declarationMap: false,
},
exclude: ['**/__tests__/*.test.*'],
},
}),
],
output: [
{
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: '__chunk__/[name].js',
format: 'es',
// 为了兼容新语法,使用 babel 转译一下
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
},
{
dir: 'dist',
entryFileNames: '[name].cjs',
chunkFileNames: '__chunk__/[name].cjs',
format: 'cjs',
exports: 'auto',
// 为了兼容新语法,使用 babel 转译一下
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
}
],
},
{
input: 'src/index.tsx',
output: {
file: 'dist/index.d.ts',
format: 'es',
},
external: config.external,
plugins: [dts()],
}
]