-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
38 lines (35 loc) · 1 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
const path = require('path');
const babel = require('@rollup/plugin-babel');
const commonjs = require('@rollup/plugin-commonjs');
const resolve = require('@rollup/plugin-node-resolve');
const terser = require('@rollup/plugin-terser');
const extensions = ['.mjs', '.js', '.json', '.node', '.ts'];
const env = process.env.NODE_ENV ?? 'development';
module.exports = {
input: './src/index.ts',
external: [/@babel\/runtime/, /antlr4ts/],
plugins: [
resolve({ extensions }),
commonjs(),
babel({
extensions,
babelHelpers: 'runtime',
exclude: /node_modules/,
configFile: path.resolve(__dirname, 'babel.config.js'),
}),
],
output: [
{
dir: 'dist/cjs',
format: 'cjs',
exports: 'named',
sourcemap: env === 'production' ? true : 'inline',
plugins: [terser({ compress: true, mangle: true, output: { comments: false } })],
},
{
dir: 'dist/esm',
format: 'es',
sourcemap: env === 'production' ? true : 'inline',
},
],
};