This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
rollup.config.js
95 lines (90 loc) · 2.09 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
import json from 'rollup-plugin-json'
import nodeResolve from 'rollup-plugin-node-resolve'
import typescript from 'rollup-plugin-typescript'
import copy from 'rollup-plugin-copy'
// @ts-ignore
import pkg from './package.json'
const version = process.env.VERSION || pkg.version
const external = Object.keys(pkg.dependencies || {})
const banner = `/**
* Nuxtent v${version}
* (c) ${new Date().getFullYear()} César Valadez
* @license MIT
*/
`
const corePlugins = [
typescript(),
nodeResolve({
preferBuiltins: true
}),
json({
preferConst: true
}),
]
const bundle = (name, options) => ({
input: `lib/${name}.ts`,
output: [{
file: `dist/${name}.js`,
format: 'cjs',
exports: 'named',
banner,
name: `nuxtent`,
globals: options.globals || {}
},
{
file: `dist/${name}.mjs`,
format: 'esm',
exports: 'named',
banner,
name: `nuxtent`,
globals: options.globals || {}
}
],
plugins: options.plugins || [...corePlugins],
external: options.external || [...external]
})
export default [
bundle('module', {
plugins: [...corePlugins, copy({
targets: {
'lib/plugins/nuxtent-components.template.js': 'dist/plugins/nuxtent-components.template.js',
'lib/plugins/nuxtent-config.template.js': 'dist/plugins/nuxtent-config.template.js'
}
})],
external: [
'path', 'fs',
...external
],
globals: {
process: {}
}
}),
bundle('loader', {
plugins: [...corePlugins],
globals: {
process: {}
},
external: ['path', 'fs', ...external]
}),
{
input: 'lib/plugins/nuxtent-request.ts',
plugins: [...corePlugins],
output: [
{
file: `dist/plugins/nuxtent-request.js`,
format: 'esm',
exports: 'named',
name: `nuxtent`,
globals: {process: {}}
}
],
external: [...external, 'url', 'stream', 'http', 'https', 'zlib']
},
// bundle('plugins/nuxtent-request', {
// plugins: [...corePlugins],
// globals: {
// process: {}
// },
// external: ['path', 'fs', ...external]
// })
]