forked from emn178/js-sha256
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
88 lines (79 loc) · 1.71 KB
/
Copy pathrollup.config.js
File metadata and controls
88 lines (79 loc) · 1.71 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
/*
* This file is part of js-sha256
*
* Copyright (c) 2025 Chen, Yi-Cyuan
* All rights belong to Chen, Yi-Cyuan
*/
/**************************************************************************
* IMPORTS
***************************************************************************/
// NPM
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
// Common plugins configuration
const basePlugins = [
// Resolve dependencies
resolve({
browser: true
}),
// Convert CommonJS modules
commonjs(),
// Minify and enable tree shaking
terser({
compress: {
passes: 2,
dead_code: true,
drop_console: true
},
format: {
comments: false
}
})
];
// Build configurations for different formats
export default [
// IIFE build (for direct browser usage)
{
input: "src/sha256.js",
output: {
file: "dist/sha256.iife.js",
format: "iife",
name: 'sha256',
sourcemap: true
},
plugins: basePlugins,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false
}
},
// ESM build (for modern bundlers)
{
input: "src/sha256.js",
output: {
file: "dist/sha256.esm.js",
format: "esm",
sourcemap: true
},
plugins: basePlugins,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false
}
},
// CommonJS build (for Node.js)
{
input: "src/sha256.js",
output: {
file: "dist/sha256.cjs.js",
format: "cjs",
sourcemap: true
},
plugins: basePlugins,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false
}
}
];