-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
106 lines (102 loc) · 2.59 KB
/
rollup.config.js
File metadata and controls
106 lines (102 loc) · 2.59 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Run this config file with the following command:
// npx rollup -c rollup.config.js
//
// This will generate the following files in the dist folder:
// 1. makelab.math.js and makelab.math.min.js
// 2. makelab.graphics.js and makelab.graphics.min.js
// 3. makelab.logo.js and makelab.logo.min.js
// 4. makelab.all.js and makelab.all.min.js
import { defineConfig } from 'rollup';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import terser from '@rollup/plugin-terser';
import { fileURLToPath } from 'url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const commonPlugins = [
resolve(),
alias({
entries: [
{ find: '@lib', replacement: path.resolve(__dirname, 'src/lib') },
{ find: '@graphicslib', replacement: path.resolve(__dirname, 'src/lib/graphics') },
{ find: '@mathlib', replacement: path.resolve(__dirname, 'src/lib/math') },
{ find: '@apps', replacement: path.resolve(__dirname, 'src/apps') },
{ find: '@dist', replacement: path.resolve(__dirname, 'dist') }
]
}),
];
export default defineConfig([
// Bundle for makelab.math.js
{
input: './src/lib/math/index.js',
output: [
{
file: 'dist/makelab.math.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/makelab.math.min.js',
format: 'es',
sourcemap: false,
plugins: [terser()],
},
],
plugins: commonPlugins,
},
// Bundle for makelab.graphics.js
{
input: './src/lib/graphics/index.js',
output: [
{
file: 'dist/makelab.graphics.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/makelab.graphics.min.js',
format: 'es',
sourcemap: false,
plugins: [terser()],
},
],
plugins: commonPlugins,
},
// Bundle for makelab.logo.js
{
input: './src/lib/logo/index.js',
output: [
{
file: 'dist/makelab.logo.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/makelab.logo.min.js',
format: 'es',
sourcemap: false,
plugins: [terser()],
},
],
plugins: commonPlugins,
},
// Bundle for makelab.all.js
{
input: './src/lib/index.js',
output: [
{
file: 'dist/makelab.all.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/makelab.all.min.js',
format: 'es',
sourcemap: false,
plugins: [terser()],
},
],
plugins: commonPlugins,
},
]);