forked from lian-yue/vue-upload-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
109 lines (94 loc) · 3.08 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
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'
module.exports = [
config,
configPart,
configSSR,
configUmd,
configPartUmd,
configMin,
]