-
Notifications
You must be signed in to change notification settings - Fork 33
/
rollup.config.js
94 lines (83 loc) · 1.88 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
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Bundle up for release.
*/
import string from '@bkuri/rollup-plugin-string';
import image from '@rollup/plugin-image';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import url from '@rollup/plugin-url';
import gitInfo from 'rollup-plugin-git-info';
const plugins = [
resolve({
mainFields: ['module', 'jsnext:main'],
preferBuiltins: false
}),
];
if (process.env.NODE_ENV === 'production') {
plugins.push(terser());
}
// Common output settings.
const output = {
// This only disables the '__esModule' symbol hack.
esModule: false,
format: 'es',
indent: false,
preferConst: true,
};
/**
* Helper for building up deps.
*
* @param {string} name
* @return {!Object}
*/
function dep(name) {
return {
input: `js/deps_${name}.shim.js`,
output: {
...output,
file: `js/deps_${name}.rollup.js`,
},
plugins,
};
}
// The files we'll build. The deps target must be first.
let targets = [
// Resources.
{
input: 'js/deps_resources.shim.js',
output: {
...output,
file: 'dist/js/hterm_resources.js',
},
external: [
'../../../libdot/index.js',
],
plugins: [
...plugins,
// Always run terser on these files as it's all generated anyways.
terser(),
gitInfo(),
string({include: ['**/*.html', '**/*.svg']}),
image({exclude: "**/*.svg"}),
url({include: ['**/*.ogg']}),
],
},
// 3rd party deps.
dep('punycode'),
// Main lib.
{
input: 'index.js',
output: {
...output,
file: 'dist/js/hterm.js',
},
plugins,
},
];
if (process.env.LIBAPPS_DEPS_ONLY !== undefined) {
targets = targets.slice(0, 1);
}
export default [...targets];