forked from mikeerickson/validatorjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
51 lines (49 loc) · 1.31 KB
/
rollup.config.mjs
File metadata and controls
51 lines (49 loc) · 1.31 KB
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
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { readdirSync } from 'node:fs';
import { join } from 'node:path';
// collect all language files from src/lang
const langDir = 'src/lang';
const langInputs = readdirSync(langDir)
.filter((f) => f.endsWith('.js'))
.map((f) => join(langDir, f));
// Rollup configuration for building core + language bundles
export default [
// Core library bundles
{
input: 'src/validator.js',
output: [
{ file: 'dist/index.cjs', format: 'cjs', exports: 'default' },
{ file: 'dist/index.esm.js', format: 'esm' },
{ name: 'Validator', file: 'dist/validator.umd.js', format: 'umd' }
],
plugins: [
resolve(),
commonjs({
dynamicRequireTargets: [
// include using a glob pattern (either a string or an array of strings)
'src/lang/*.js',
],
}),
],
},
// Language bundles (one file per language)
{
input: langInputs,
output: [
{
dir: 'dist/lang',
format: 'cjs',
preserveModules: true,
entryFileNames: '[name].js',
},
{
dir: 'dist/lang',
format: 'esm',
preserveModules: true,
entryFileNames: '[name].mjs',
},
],
plugins: [resolve(), commonjs()],
}
];