forked from apih/quival
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
77 lines (69 loc) · 1.75 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
import fs from 'fs';
import path from 'path';
import swc from '@rollup/plugin-swc';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import prettier from 'rollup-plugin-prettier';
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const banner = `/*!
* ${pkg.name} v${pkg.version} (${pkg.repository.url})
* (c) 2023 ${pkg.author}
* Released under the MIT License.
*/`;
const options = [
{
input: 'src/index.js',
output: [
{
file: 'dist/quival.js',
format: 'iife',
name: 'quival',
banner,
plugins: [prettier(JSON.parse(fs.readFileSync('.prettierrc.json')))],
},
{
file: 'dist/quival.min.js',
format: 'iife',
name: 'quival',
banner,
plugins: [terser()],
},
],
plugins: [
resolve(),
swc({
swc: {
env: {
targets: 'last 1 year',
mode: 'entry',
coreJs: '3.22',
},
},
exclude: 'node_modules/**',
}),
],
},
];
const srcLocales = 'src/locales';
const distLocales = 'dist/locales';
const filenames = fs.readdirSync(srcLocales).filter((filename) => path.extname(filename) === '.js');
for (const filename of filenames) {
const basename = path.basename(filename, '.js');
const format = 'iife';
const name = `quival.locales.${basename}`;
const normal = {
file: path.join(distLocales, `${basename}.js`),
format,
name,
banner,
};
const minified = Object.assign({}, normal, {
file: path.join(distLocales, `${basename}.min.js`),
plugins: [terser()],
});
options.push({
input: path.join(srcLocales, filename),
output: [normal, minified],
});
}
export default options;