-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
59 lines (54 loc) · 1.38 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import alias from '@rollup/plugin-alias';
export default [
// Browser-friendly UMD build
{
input: 'src/index.js',
output: {
name: 'ThermalPrinterEncoder',
file: 'dist/thermal-printer-encoder.umd.js',
format: 'umd',
},
plugins: [
/* Make sure we force the browser version of canvas */
alias({
entries: [
{ find: 'canvas', replacement: 'node_modules/canvas/browser.js' },
],
}),
resolve(),
commonjs(),
terser(),
],
},
// Browser-friendly ES module build
{
input: 'src/index.js',
output: {
file: 'dist/thermal-printer-encoder.esm.js',
format: 'es',
},
plugins: [
/* Make sure we force the browser version of canvas */
alias({
entries: [
{ find: 'canvas', replacement: 'node_modules/canvas/browser.js' },
],
}),
resolve(),
commonjs(),
terser(),
],
},
// CommonJS (for Node) and ES module (for bundlers) build
{
input: 'src/index.js',
external: ['esc-pos-encoder', 'star-prnt-encoder'],
output: [
{ file: 'dist/thermal-printer-encoder.cjs', format: 'cjs' },
{ file: 'dist/thermal-printer-encoder.mjs', format: 'es' },
],
},
];