-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtemplate-rollup.config.js
More file actions
44 lines (42 loc) · 979 Bytes
/
Copy pathtemplate-rollup.config.js
File metadata and controls
44 lines (42 loc) · 979 Bytes
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
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import fs from 'fs';
const metaPath = new URL('package.json', import.meta.url).pathname;
const meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
const name = meta.name.split('/').pop();
const umd = meta.umd || name;
export default [
{
input: 'src/main.js',
output: [
{
file: `dist/${name}.mjs`,
format: 'esm',
},
{
file: `dist/${name}.cjs`,
format: 'cjs',
},
],
plugins: [resolve(), commonjs()],
},
{
input: 'src/main.js',
output: {
file: `dist/${name}.umd.js`,
format: 'umd',
name: umd,
},
plugins: [resolve(), commonjs()],
},
{
input: 'src/main.js',
output: {
file: `dist/${name}.umd.min.js`,
format: 'umd',
name: umd,
},
plugins: [resolve(), commonjs(), terser()],
},
];