-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
73 lines (66 loc) · 1.43 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
73
import vue from 'rollup-plugin-vue'
import scss from 'rollup-plugin-scss'
const pkg = require('./package.json')
function getAuthors(pkg) {
const { contributors, author } = pkg
const authors = new Set()
if (contributors && contributors)
contributors.forEach((contributor) => {
authors.add(contributor.name)
})
if (author) authors.add(author.name)
return Array.from(authors).join(', ')
}
const banner = `/*!
* ${pkg.name} v${pkg.version}
* (c) ${new Date().getFullYear()} ${getAuthors(pkg)}
* @license ${pkg.license}
*/`
const outputConfigs = {
// each file name has the format: `dist/${name}.${format}.js`
// format being a key of this object
'esm-bundler': {
file: pkg.module,
format: `es`,
},
cjs: {
file: pkg.main,
format: `cjs`,
},
global: {
file: pkg.unpkg,
format: `iife`,
},
esm: {
file: pkg.browser || pkg.module.replace('-bundler.js', '-browser.js'),
format: `es`,
},
}
export default [
// ESM build to be used with webpack/rollup.
{
input: 'src/index.js',
output: {
format: 'esm',
file: pkg.module,
},
plugins: [vue()],
},
{
input: 'src/scss/main.scss',
output: {
file: pkg.module,
format: 'esm',
},
plugins: [scss()],
},
// SSR build.
{
input: 'src/index.js',
output: {
format: 'cjs',
file: pkg.main,
},
plugins: [vue({ template: { optimizeSSR: true } })],
},
]