-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
rollup.config.js
83 lines (78 loc) · 1.8 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const merge = require('deepmerge')
const { defineConfig } = require('rollup')
const resolve = require('rollup-plugin-node-resolve')
const babel = require('@rollup/plugin-babel').default
const replace = require('@rollup/plugin-replace')
const { terser } = require('rollup-plugin-terser')
const vue = require('rollup-plugin-vue')
const typescript = require('rollup-plugin-typescript')
const pkg = require('./package.json')
const baseConfig = defineConfig({
external(id) {
if (id === 'vue') return true
if (id === 'index.vue' || id === './components/index') return false
},
input: path.resolve('./packages/index.ts'),
plugins: [
replace({
values: {
__DEV__: "process.env.NODE_ENV !== 'production'",
__VERSION__: pkg.version
},
preventAssignment: true
}),
typescript(),
vue(),
resolve(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled'
})
],
output: {
name: 'Vue3baiduMapGl',
format: 'umd',
exports: 'named',
globals: {
vue: 'Vue'
}
}
})
const devConfig = defineConfig({
output: {
file: path.resolve('dist/index.js')
}
})
const prodConfig = defineConfig({
plugins: [
replace({
values: {
'process.env.NODE_ENV': JSON.stringify('production')
},
preventAssignment: true
}),
terser()
],
output: {
file: path.resolve('dist/index.prod.js')
}
})
const esmConfig = defineConfig({
output: {
globals: {
vue: 'Vue'
},
format: 'esm',
file: path.resolve('dist/index.esm.js')
}
})
module.exports = [
// dev umd output
merge(baseConfig, devConfig),
// prod umd output
merge(baseConfig, prodConfig),
// esm output
merge(baseConfig, esmConfig)
]