-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
115 lines (109 loc) · 2.53 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
110
111
112
113
114
115
import { config } from 'dotenv';
import { readFileSync } from 'fs';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import cleanup from 'rollup-plugin-cleanup';
import multi from '@rollup/plugin-multi-entry';
import externals from 'rollup-plugin-external-globals';
import css from 'rollup-plugin-import-css';
import replace from '@rollup/plugin-replace';
import { version } from './package.json';
config();
const debug = process.argv.includes('--configDebug');
const exclude = ['**/*.ignore/*', '**/*.ignore*'];
if (!debug) {
exclude.push(
'**/*.local/*',
'**/*.local*',
);
}
const meta = readFileSync('./src/meta.js').toString().replace(/{{ version }}/g, version);
const {
SENTRY_DSN = '',
} = process.env;
export default [{
input: 'src/bundle/bundle.js',
treeshake: false,
watch: false,
output: {
file: 'dist/dependencies.js',
format: 'cjs',
},
context: 'this',
plugins: [
nodeResolve({ browser: true }),
commonjs(),
json(),
cleanup(),
],
}, {
input: {
include: [
'src/utils/0.publicist.js',
'src/base/index.js',
'src/base/**/*.js',
'src/hooks/**/*.js',
],
exclude,
},
context: 'this',
output: [{
name: 'ucs',
file: 'dist/undercards.user.js',
banner: meta,
format: 'module', // module, iife
esModule: false,
exports: 'none',
preferConst: true,
}, {
name: 'ucs',
file: 'dist/underscript.js',
format: 'iife', // module, iife
esModule: false,
exports: 'none',
preferConst: true,
}],
external: ['luxon', 'showdown', 'axios', 'tippy.js'],
plugins: [
replace({
preventAssignment: true,
values: {
VERSION: `'${version}'`,
__SENTRY__: SENTRY_DSN,
__VERSION__: version,
__ENVIRONMENT__: process.env.GITHUB_ACTIONS ? 'production' : 'development',
},
}),
nodeResolve({ browser: true }),
css(),
multi({
exports: false,
}),
cleanup(),
externals({
luxon: 'luxon',
showdown: 'showdown',
axios: 'axios',
'tippy.js': 'tippy',
}),
{
name: 'Meta saver',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'undercards.meta.js',
source: meta,
});
},
},
{
name: 'Watch src',
buildStart() {
// Look for new files in base/hooks
this.addWatchFile('src/base');
this.addWatchFile('src/hooks');
},
},
],
}];