-
Notifications
You must be signed in to change notification settings - Fork 694
/
rollup.config.js
144 lines (115 loc) · 3.98 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
import path from 'path'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { babel, getBabelOutputPlugin } from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser'
import postcss from 'rollup-plugin-postcss'
import vue from 'rollup-plugin-vue'
import packageInfo from './package.json'
import typescript from 'rollup-plugin-typescript2';
import pluginCSS from 'rollup-plugin-css-only';
function baseConfig(css, ssr, umd, min) {
let res = {
input: 'src/FileUpload.vue',
output: {
format: umd ? 'umd' : 'esm',
// format: 'iife',
sourcemap: true,
banner: umd ? `/*!\n Name: ${ packageInfo.name } \nComponent URI: ${ packageInfo.homepage } \nVersion: ${ packageInfo.version } \nAuthor: ${ packageInfo.author } \nLicense: ${ packageInfo.license } \nDescription: ${ packageInfo.description } \n */` : '',
globals: {
vue: 'Vue',
},
name: "VueUploadComponent",
},
external: ['vue'],
plugins: [
resolve({
jsnext: true,
main: true,
browser: true,
}),
css && pluginCSS(),
vue({
preprocessStyles: true,
css: css,
target: ssr ? 'node' : 'browser',
}),
typescript({
declaration: true,
check: true,
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
}),
postcss(),
ssr || umd ? false : babel({
exclude: 'node_modules/**'
}),
ssr || umd ? false : getBabelOutputPlugin({
"presets": [
["@babel/preset-env", { "modules": false, "useBuiltIns": false, "targets": "ie >= 9", "exclude": ["transform-async-to-generator", "proposal-async-generator-functions", "transform-regenerator"] }]
],
"sourceType": "unambiguous",
"plugins": [
["@babel/plugin-transform-runtime", { "helpers": false, "corejs": false, "regenerator": false, "useESModules": false, "absoluteRuntime": false }]
],
}),
min ? terser({
output: {
comments: /^!/,
}
}) : false,
commonjs({
extensions: [
'.js',
'.ts',
'.vue'
],
}),
],
}
return res
}
let config = baseConfig(false, false)
config.output.file = 'dist/vue-upload-component.js'
let configPart = baseConfig(true, false)
configPart.output.file = 'dist/vue-upload-component.part.js'
let configSSR = baseConfig(false, true, true)
configSSR.output.file = 'dist/vue-upload-component.ssr.js'
let configUmd = baseConfig(false, false, true)
configUmd.input = config.output.file
configUmd.output.file = config.output.file
let configPartUmd = baseConfig(false, false, true)
configPartUmd.input = configPart.output.file
configPartUmd.output.file = configPart.output.file
let configMin = baseConfig(false, false, true, true)
configMin.input = config.output.file
configMin.output.file = 'dist/vue-upload-component.min.js'
let configEsm = baseConfig(false, false, false)
configEsm.output.file = 'dist/vue-upload-component.esm.js'
let configEsmPart = baseConfig(true, false, false)
configEsmPart.output.file = 'dist/vue-upload-component.esm.part.js'
let configEsmSSR = baseConfig(false, true, false)
configEsmSSR.output.file = 'dist/vue-upload-component.esm.ssr.js'
let configEsmUmd = baseConfig(false, false, false)
configEsmUmd.input = configEsm.output.file
configEsmUmd.output.file = configEsm.output.file
let configEsmPartUmd = baseConfig(false, false, false)
configEsmPartUmd.input = configEsmPart.output.file
configEsmPartUmd.output.file = configEsmPart.output.file
let configEsmMin = baseConfig(false, false, false, true)
configEsmMin.input = configEsm.output.file
configEsmMin.output.file = 'dist/vue-upload-component.esm.min.js'
module.exports = [
config,
configPart,
configSSR,
configUmd,
configPartUmd,
configMin,
configEsm,
configEsmPart,
configEsmSSR,
configEsmUmd,
configEsmPartUmd,
configEsmMin,
]