-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
66 lines (63 loc) · 1.74 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
import path from 'path';
import copy from 'rollup-plugin-copy';
import json from '@rollup/plugin-json';
import babel from '@rollup/plugin-babel';
import esbuild from 'rollup-plugin-esbuild';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import packageJson from './package.json';
const pkg = `${packageJson.name}.bobplugin`;
const RollupConfig = {
input: path.join(__dirname, './src/main.ts'),
output: {
format: 'cjs',
exports: 'auto',
file: path.join(__dirname, `./dist/${pkg}/main.js`),
globals: {
$util: '$util',
$http: '$http',
$info: '$info',
$option: '$option',
$log: '$log',
$data: '$data',
$file: '$file',
}
},
plugins: [
copy({
targets: [
{ src: './src/info.json', dest: `dist/${pkg}/` },
{ src: './src/libs', dest: `dist/${pkg}/` },
],
}),
json({ namedExports: false }),
resolve({
extensions: ['.js', '.ts', '.json'],
preferBuiltins: false,
}),
commonjs(),
nodePolyfills(),
babel({
extensions: ['.js', '.ts'],
babelHelpers: 'bundled',
exclude: 'node_modules/**',
}),
esbuild({
// All options are optional
include: /\.[jt]?s$/, // default, inferred from `loaders` option
exclude: /node_modules/, // default
sourceMap: false, // default
minify: process.env.NODE_ENV === 'production',
target: 'es6', // default, or 'es20XX', 'esnext',
// Add extra loaders
loaders: {
// Add .json files support
// require @rollup/plugin-commonjs
'.json': 'json',
},
}),
],
external: ['crypto-js']
};
export default RollupConfig;