-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.esnext.config.js
50 lines (46 loc) · 1.21 KB
/
rollup.esnext.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
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import pkg from './package.json' assert { type: 'json' };
import fs from 'fs';
import path from 'path';
function customReplacer() {
return {
name: 'custom-dts-replacer', // Name the plugin
writeBundle() {
const file = path.join(process.cwd(), 'dist', 'esnext', 'index.d.ts');
if (fs.existsSync(file)) {
let content = fs.readFileSync(file, 'utf8');
content = content
.replace(/__NAME__/g, pkg.name)
.replace(/__VERSION__/g, pkg.version)
.replace(/__LICENSE__/g, pkg.license);
fs.writeFileSync(file, content, 'utf8');
}
},
};
}
export default {
input: './src/index.ts',
output: {
file: 'dist/esnext/index.js',
format: 'module',
sourcemap: true,
name: 'skinTone',
},
plugins: [
replace({
preventAssignment: true,
values: {
__NAME__: pkg.name,
__VERSION__: pkg.version,
__LICENSE__: pkg.license,
},
}),
nodeResolve(),
typescript({
tsconfig: './tsconfig.esnext.json',
}),
customReplacer(),
],
};