forked from atomiks/tippyjs-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
49 lines (43 loc) · 1.3 KB
/
Copy pathbuild.js
File metadata and controls
49 lines (43 loc) · 1.3 KB
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
const { rollup } = require('rollup')
const babel = require('rollup-plugin-babel')
const minify = require('rollup-plugin-babel-minify')
const resolve = require('rollup-plugin-node-resolve')
const pluginBabel = babel({
babelrc: false,
exclude: 'node_modules/**',
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true }]
]
})
const pluginMinify = minify({ comments: false })
const pluginResolve = resolve()
const rollupConfig = (...plugins) => ({
input: './src/Tippy.js',
plugins: [pluginBabel, pluginResolve, ...plugins],
external: ['tippy.js', 'react', 'react-dom', 'prop-types']
})
const output = format => file => ({
name: 'Tippy',
format,
file,
sourcemap: true,
globals: {
'tippy.js': 'tippy',
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes'
}
})
const umd = output('umd')
const esm = output('es')
const build = async () => {
const bundle = await rollup(rollupConfig())
const bundleMin = await rollup(rollupConfig(pluginMinify))
bundle.write(umd('./dist/Tippy.js'))
bundleMin.write(umd('./dist/Tippy.min.js'))
bundle.write(esm('./dist/esm/Tippy.js'))
bundleMin.write(esm('./dist/esm/Tippy.min.js'))
}
build()