This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrollup.config.js
95 lines (90 loc) · 2.57 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { nodeResolve } from '@rollup/plugin-node-resolve';
import css from 'rollup-plugin-import-css';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import sass from 'rollup-plugin-sass';
import cssnano from 'cssnano';
import postcss from 'postcss';
import { existsSync } from 'fs';
import { mkdir, writeFile } from 'fs/promises';
import { dirname } from 'path';
export default [
// ES6 standalone files
{
input: 'src/js/jooa11y.js',
plugins: [
nodeResolve(),
css(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
output: [
{ file: 'dist/js/joomla-a11y-checker.esm.js', format: 'esm' },
{
file: 'dist/js/joomla-a11y-checker.esm.min.js', format: 'esm', plugins: [terser()],
},
],
},
// UMD standalone files
{
input: 'src/js/jooa11y.js',
plugins: [
nodeResolve(),
css(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
output: [
{ file: 'dist/js/joomla-a11y-checker.umd.js', format: 'umd', name: 'Jooa11y'},
{
file: 'dist/js/joomla-a11y-checker.umd.min.js', format: 'umd', name: 'Jooa11y', plugins: [terser()],
},
],
},
{
input: 'src/js/lang/en.js',
plugins: [nodeResolve()],
output: [
{ file: 'dist/js/lang/en.js', format: 'esm' },
],
},
{
input: 'src/js/lang/en.js',
plugins: [nodeResolve()],
output: [
{ file: 'dist/js/lang/en.umd.js', format: 'umd', name: 'Jooa11yLangEn'},
],
},
// SCSS files
{
input: 'src/scss/jooa11y.scss',
plugins: [sass({
output: false,
processor: (css) => {
postcss()
.process(css, { from: undefined })
.then(async (result) => {
const path = 'dist/css/joomla-a11y-checker.css';
const pathMin = 'dist/css/joomla-a11y-checker.min.css';
if (!existsSync(dirname(path))) {
await mkdir(dirname(path), { recursive: true });
}
await writeFile(path, result.css, { encoding: 'utf8' });
postcss([cssnano])
.process(result.css, { from: undefined })
.then(async (result) => {
if (!existsSync(dirname(pathMin))) {
await mkdir(dirname(pathMin), { recursive: true });
}
await writeFile(pathMin, result.css, { encoding: 'utf8' });
});
});
return '';
},
})],
},
];