-
Notifications
You must be signed in to change notification settings - Fork 43
/
rollup.config.js
50 lines (46 loc) · 1.56 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
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import { defineConfig } from 'rollup';
const isProductionBuild = process.env.PRODUCTION_BUILD === 'true';
const basePlugins = [
commonjs(),
json(),
nodeResolve({
// see here: https://github.com/rollup/plugins/tree/master/packages/node-resolve#exportconditions
// this is required to get chalk working properly
exportConditions: ['node'],
preferBuiltins: true,
}),
];
// only minify when doing a "production" build (i.e., for a release)
// it takes a lot longer!
if (isProductionBuild) {
basePlugins.push(terser());
}
export default defineConfig([
{
input: 'bin/run.js',
output: { file: 'dist-gha/run.cjs', format: 'cjs', inlineDynamicImports: true },
plugins: basePlugins,
},
{
input: 'dist/index.js',
output: { file: 'dist-gha/commands.js', format: 'esm', inlineDynamicImports: true },
plugins: [
...basePlugins,
// this disgusting workaround is required to prevent runtime errors,
// see https://github.com/JS-DevTools/ono/issues/19
replace({
delimiters: ['', ''],
preventAssignment: true,
values: {
'if (typeof module === "object" && typeof module.exports === "object") {':
'if (typeof module === "object" && typeof module.exports === "object" && typeof module.exports.default === "object") {',
},
}),
],
},
]);