-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrollup.config.js
More file actions
70 lines (65 loc) · 1.9 KB
/
Copy pathrollup.config.js
File metadata and controls
70 lines (65 loc) · 1.9 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { defineConfig } from 'rollup';
import copy from 'rollup-plugin-copy';
import fs from 'fs';
import { string } from 'rollup-plugin-string';
import { minify } from 'html-minifier-terser';
function minifyHTMLPlugin() {
const files = ['src/html/editor.html', 'src/html/form-input.html'];
return {
name: 'minify-html',
async buildStart() {
for (const file of files) {
const input = fs.readFileSync(file, 'utf8');
const output = await minify(input, {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
minifyCSS: true,
minifyJS: true,
});
const outFile = file.replace('.html', '.min.html');
fs.writeFileSync(outFile, output);
}
},
};
}
export default defineConfig({
input: 'src/index.js',
output: [
{
file: 'dist/guimath.esm.js',
format: 'es',
},
{
file: 'dist/guimath.umd.js',
format: 'umd',
name: 'GUIMath',
exports: 'default',
},
{
file: 'dist/guimath.min.js',
format: 'umd',
name: 'GUIMath',
},
{
file: 'docs/js/guimath.min.js',
format: 'umd',
name: 'GUIMath',
},
],
plugins: [
minifyHTMLPlugin(),
copy({
targets: [
{ src: 'src/guimath.css', dest: 'dist' },
{ src: 'src/guimath.css', dest: 'docs/css' },
{ src: 'src/fonts/*', dest: 'dist/fonts' },
{ src: 'src/fonts/*', dest: 'docs/css/fonts' },
],
}),
string({
include: '**/*.html',
}),
],
});