-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
71 lines (64 loc) · 1.82 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
const path = require('path');
const resolve = require('@rollup/plugin-node-resolve');
const terser = require('@rollup/plugin-terser');
const alias = require('@rollup/plugin-alias');
const { getFileNamesRecursive } = require('./.rollup/utils/get-file-names-recursive');
const production = process.env.BUILD === 'production';
const plugins = [
resolve(),
alias({
entries: [
{
find: '@validator',
replacement: path.join(__dirname, './src/validator'),
},
{
find: '@parser',
replacement: path.join(__dirname, './src/parser'),
},
{
find: '@tags',
replacement: path.join(__dirname, './src/tags'),
},
{
find: '@tags-validation',
replacement: path.join(__dirname, './src/tags-validation'),
},
{
find: '@interpreter',
replacement: path.join(__dirname, './src/interpreter'),
},
{
find: '@schema',
replacement: path.join(__dirname, './src/schema'),
},
],
}),
];
const fileNamesFilter = (fileName) => {
return fileName.endsWith('.test.js') !== true;
};
const fileNames = getFileNamesRecursive('./src', fileNamesFilter);
if (production) {
plugins.push(
terser({
compress: {
properties: true,
reduce_funcs: true,
reduce_vars: true,
drop_console: true,
keep_fargs: false,
},
}),
);
}
module.exports = {
input: fileNames,
output: {
dir: 'dist/',
format: 'cjs',
entryFileNames: '[name].js',
preserveModules: true,
},
plugins,
};