forked from buttons/github-buttons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
113 lines (107 loc) · 2.37 KB
/
rollup.config.js
File metadata and controls
113 lines (107 loc) · 2.37 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import coffeescript from 'rollup-plugin-coffee-script'
import resolve from 'rollup-plugin-node-resolve'
import { uglify } from 'rollup-plugin-uglify'
const raw = function ({ name, test, transform = (code) => code }) {
return {
name,
transform (code, id) {
if (!test(id)) return null
code = `export default ${JSON.stringify(transform(code))}`
const ast = {
type: 'Program',
sourceType: 'module',
start: 0,
end: code.length,
body: [{
type: 'ExportDefaultDeclaration',
start: 0,
end: code.length,
declaration: {
type: 'Literal',
start: 15,
end: code.length,
value: null,
raw: 'null'
}
}]
}
return { ast, code, map: { mappings: '' } }
}
}
}
export default [
{
input: 'src/main.coffee',
output: {
format: 'iife',
file: 'dist/buttons.js'
}
}, {
input: 'src/main.coffee',
output: {
format: 'iife',
file: 'dist/buttons.min.js'
}
}, {
input: 'src/container.coffee',
output: {
format: 'es',
file: 'dist/buttons.esm.js'
}
}, {
input: 'src/container.coffee',
output: {
format: 'cjs',
file: 'dist/buttons.common.js'
}
}, {
input: 'src/app.coffee',
output: {
format: 'iife',
file: 'assets/js/app.js'
}
}, {
input: 'src/app.coffee',
output: {
format: 'iife',
file: 'assets/js/app.min.js'
}
}
].map(config => Object.assign({
plugins: [
resolve({
extensions: ['.coffee', '.js', '.json']
}),
coffeescript(),
raw({
name: 'css',
test (id) {
return id.endsWith('css')
}
}),
raw({
name: 'octicons-data-json',
test (id) {
return id.endsWith('/node_modules/octicons/build/data.json')
},
transform (code) {
const data = JSON.parse(code)
return Object.assign({}, ...[
'mark-github',
'eye',
'star',
'repo-forked',
'issue-opened',
'cloud-download'
].map(key => ({
[key]: {
width: data[key].width,
height: data[key].height,
path: data[key].path
}
})))
}
}),
...(/\.min\.js$/.test(config.output.file) ? [uglify()] : [])
]
}, config))