forked from ts1/flipbook-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
72 lines (67 loc) · 1.8 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
66
67
68
69
70
71
72
import buble from '@rollup/plugin-buble'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import url from '@rollup/plugin-url'
import vue from 'rollup-plugin-vue'
import vue2 from 'rollup-plugin-vue2'
import coffeescript from 'rollup-plugin-coffee-script'
import { terser } from 'rollup-plugin-terser'
import autoprefixer from 'autoprefixer'
import { name, version } from './package.json'
import styles from 'rollup-plugin-styles'
const banner = `/*!
* @license
* ${name} v${version}
* Copyright © ${new Date().getFullYear()} Takeshi Sone.
* Released under the MIT License.
*/
`
const plugins = (vue, minify = false) => {
const plugins = [
vue({
needMap: false,
template: { isProduction: true },
}),
styles({
plugins: [autoprefixer()],
minimize: true,
}),
resolve({ extensions: ['.js', '.vue', '.coffee'] }),
commonjs(),
coffeescript(),
buble(),
url(),
]
if (minify) {
plugins.push(terser({ output: { comments: /copyright|license/i } }))
}
return plugins
}
const modules = (vue, dist) => ({
input: 'src/Flipbook.vue',
external: ['rematrix', 'vue'],
output: [
{ banner, format: 'es', file: `${dist}/flipbook.mjs` },
{ banner, format: 'cjs', file: `${dist}/flipbook.cjs.js`, exports: 'default' }
],
plugins: plugins(vue),
})
const browser = (vue, dist, minify) => ({
input: 'src/wrapper.coffee',
external: ['vue'],
output: {
banner,
format: 'iife',
file: `${dist}/flipbook${minify ? '.min' : ''}.js`,
globals: { vue: 'Vue'}
},
plugins: plugins(vue, minify),
})
export default [
modules(vue, 'dist'),
browser(vue, 'dist', false),
browser(vue, 'dist', true),
modules(vue2, 'dist/vue2'),
browser(vue2, 'dist/vue2', false),
browser(vue2, 'dist/vue2', true),
]