-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.dev.js
62 lines (55 loc) · 1.42 KB
/
rollup.config.dev.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
const path = require('path')
const { babel } = require('@rollup/plugin-babel')
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const template = require('rollup-plugin-generate-html-template')
const commonjs = require('@rollup/plugin-commonjs')
const serve = require('rollup-plugin-serve')
const livereload = require('rollup-plugin-livereload')
const pkg = require('./package.json')
const pathResolve = (dir) => {
return path.resolve(__dirname, dir)
}
const isProduction = process.env.NODE_ENV === 'production'
const babelOptions = {
"babelHelpers": "runtime",
"presets": [
[
'@babel/env', {
"modules": false
}
]
],
"plugins": [
["@babel/plugin-transform-runtime", {
"regenerator": true
}]
]
}
const plugins = [
babel(babelOptions),
template({
template: pathResolve('./example/index.html'),
target: pathResolve('./docs/index.html'),
replaceVars: {
'__PUBLIC_PATH__CANVASTOIMAGE__': isProduction ? `https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/canvastoimage.js` : '../dist/canvastoimage.js',
}
}),
nodeResolve(),
commonjs()
]
if (!isProduction) {
plugins.push(serve({
open: true,
port: 3001
}),
livereload('./docs/'))
}
module.exports = [{
input: pathResolve('./example/index.js'),
output: [{
file: pathResolve('./docs/index.js'),
format: 'umd',
name: 'example'
}],
plugins
}, ]