-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
184 lines (150 loc) · 3.83 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* Rollup configuration inspired by: https://github.com/team-innovation/vue-sfc-rollup
*/
import resolve from '@rollup/plugin-node-resolve' // NodeJS node_modules resolution algorithm
import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6
import babel from '@rollup/plugin-babel' // Babel rollup plugin
import replace from '@rollup/plugin-replace' // Replace strings in the source-code
import postcss from 'rollup-plugin-postcss' // Extract SCSS as CSS with PostCSS and inject it in JavaScript
import vue from 'rollup-plugin-vue' // Handle the compilation of .vue SFC files
import { terser } from 'rollup-plugin-terser' // Minify generated bundle
import svg from 'rollup-plugin-svg' // Handle .svg files imports
const esmConfig = {
input: 'src/index.js',
// Dependencies to exclude in the build output.
external: ['vue'],
output: {
file: 'dist/vue3-roulette.esm.js',
format: 'esm',
exports: 'named',
// Provide global variable names to replace your external imports.
globals: {
vue: 'Vue'
}
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true
}),
svg(),
vue({
// Required to extract and re-inject SCSS styles as CSS
preprocessStyles: true,
css: true,
template: {
isProduction: true
}
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue']
}),
postcss(),
commonjs(),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {}]
]
})
]
}
const umdConfig = {
input: 'src/index.js',
// Dependencies to exclude in the build output.
external: ['vue'],
output: {
compact: true,
sourcemap: true,
file: 'dist/vue3-roulette.js',
format: 'cjs',
name: 'vue3-roulette',
exports: 'auto',
// Provide global variable names to replace your external imports.
globals: {
vue: 'Vue'
}
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true
}),
svg(),
vue({
// Required to extract and re-inject SCSS styles as CSS
preprocessStyles: true,
css: true,
template: {
isProduction: true,
optimizeSSR: true
}
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue']
}),
postcss(),
commonjs(),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {}]
]
}),
terser({
output: { ecma: 5 }
})
]
}
const iifeConfig = {
input: 'src/index.js',
// Dependencies to exclude in the build output.
external: ['vue'],
output: {
compact: true,
file: 'dist/vue3-roulette.min.js',
format: 'iife',
name: 'vue3Roulette',
exports: 'auto',
// Provide global variable names to replace your external imports.
globals: {
vue: 'Vue'
}
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true
}),
svg(),
vue({
// Required to extract and re-inject SCSS styles as CSS
preprocessStyles: true,
css: true,
template: {
isProduction: true
}
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue']
}),
postcss(),
commonjs(),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {}]
]
}),
terser({
output: { ecma: 5 }
})
]
}
export default [esmConfig, umdConfig, iifeConfig]