-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathrollup.config.js
More file actions
45 lines (41 loc) · 1.13 KB
/
rollup.config.js
File metadata and controls
45 lines (41 loc) · 1.13 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
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import pkg from "./package.json" with { type: "json" };
import * as fs from "fs";
import path from "path";
import { fileURLToPath } from 'node:url';
// ref https://rollupjs.org/command-line-interface/#getting-the-current-directory
const currentDir = fileURLToPath(new URL('.', import.meta.url))
const libFolderPath = path.join(currentDir, "./lib");
// Create lib folder
if (!fs.existsSync(libFolderPath)) {
fs.mkdirSync(libFolderPath);
}
// move index.d.ts to /lib
fs.createReadStream(path.join(currentDir, "src/index.d.ts")).pipe(
fs.createWriteStream(path.join(currentDir, "lib/index.d.ts"))
);
export default {
input: "src/index.js",
output: [
{
name: "cryptoformat",
file: pkg.browser,
format: "umd",
},
{
name: "cryptoformat",
file: pkg.main,
format: "cjs",
},
{
name: "cryptoformat",
file: pkg.module,
format: "es",
},
],
plugins: [
resolve(), // so Rollup can find `dependencies`
commonjs(), // so Rollup can convert `dependencies` to an ES module
],
};