forked from nuxt-community/nuxtent-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
75 lines (70 loc) · 1.66 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
import resolve from 'rollup-plugin-node-resolve'
import json from 'rollup-plugin-json'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import uglify from 'rollup-plugin-uglify-es'
import filesize from 'rollup-plugin-filesize'
import copy from 'rollup-plugin-copy'
import pkg from './package.json'
const version = process.env.VERSION || pkg.version
const external = Object.keys(pkg.dependencies || {})
const corePlugins = [
resolve({
preferBuiltins: false
}),
commonjs({
include: 'node_modules/**'
}),
babel({
babelrc: false,
presets: [['env', { modules: false, targets: { node: '8.0' } }], 'stage-2']
// plugins: [
// 'transform-async-to-generator',
// 'transform-regenerator',
// [
// 'transform-object-rest-spread',
// {
// useBuiltIns: true
// }
// ],
// 'external-helpers'
// ]
}),
uglify(),
filesize()
]
const bundle = (name, options) => ({
input: `lib/${name}.js`,
output: {
file: `dist/${name}.js`,
format: 'cjs',
exports: 'named'
},
name: `nuxtContent`,
plugins: options.plugins || [],
external: options.external || [],
globals: options.globals || {},
banner: `
/**
* Nuxt Content v${version}
* (c) ${new Date().getFullYear()} Alid Castano
* @license MIT
*/
`
})
export default [
bundle('module', {
plugins: [
json(),
copy({
'lib/plugins': 'dist/plugins',
'lib/loader.js': 'dist/loader.js'
}),
...corePlugins
],
external: ['path', 'fs', 'querystring', 'express', 'axios', ...external],
globals: {
express: 'express'
}
})
]