forked from yydfys/CatPawOpen
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrollup-config.js
37 lines (35 loc) · 1.02 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
import * as rollup from 'rollup';
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import fs from 'fs';
import { createHash } from 'crypto';
rollup
.rollup({
input: ['./src/index.config.js'],
plugins: [commonjs(), json()],
onwarn: function (message) {
console.log(message.toString());
},
})
.then((build) => {
build
.write({
dir: './dist',
format: 'cjs',
entryFileNames: '[name].js',
strict: false,
plugins: [genMd5()],
})
.then((output) => {
console.log(output.output.map((o) => o.fileName));
});
});
function genMd5() {
return {
name: 'gen-output-file-md5',
writeBundle() {
const md5 = createHash('md5').update(fs.readFileSync('./dist/index.config.js')).digest('hex');
fs.writeFileSync('./dist/index.config.js.md5', md5);
},
};
}