-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
83 lines (75 loc) · 2.13 KB
/
Copy pathrollup.config.js
File metadata and controls
83 lines (75 loc) · 2.13 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
71
72
73
74
75
76
77
78
79
80
81
82
83
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8'));
const short_banner = `/*! ${pkg.name} v${pkg.version} | * (c) ${new Date().getFullYear()} ${pkg.author} and contributors | ${pkg.license} License*/`;
const banner = `/*!
* ${pkg.name} v${pkg.version}
* (c) ${new Date().getFullYear()} ${pkg.author} and other contributors
*
* Released under the ${pkg.license} License
* Date: ${new Date().toISOString().split('T')[0]}
*/`;
function removeComment() {
return {
name: 'remove-sourcemap-comment',
writeBundle(outputOptions, bundle) {
for (const fileName in bundle) {
if (fileName.endsWith('.js')) {
const filePath = path.join(
outputOptions.dir || path.dirname(outputOptions.file),
fileName
);
let code = fs.readFileSync(filePath, 'utf-8');
code = code
.replace(/^\s*\/\/\s*@ts-check\s*$/gm, '')
.replace(/\/\/# sourceMappingURL=.*$/gm, '');
fs.writeFileSync(filePath, code);
}
}
},
};
}
export default [
{
input: 'src/index.js',
output: [
{
file: 'dist/exprify.esm.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/exprify.cjs.cjs',
format: 'cjs',
sourcemap: true,
exports: 'default',
},
{
file: 'dist/exprify.js',
format: 'umd',
name: 'Exprify',
banner: banner,
sourcemap: true,
indent: true,
exports: 'default',
},
],
plugins: [resolve(), commonjs(), removeComment()],
},
{
input: 'src/index.js',
output: {
file: 'dist/exprify.min.js',
format: 'umd',
name: 'Exprify',
sourcemap: true,
banner: short_banner,
},
plugins: [resolve(), commonjs(), terser(), removeComment()],
},
];