-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
40 lines (37 loc) · 1.37 KB
/
rollup.config.js
File metadata and controls
40 lines (37 loc) · 1.37 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
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import fs from 'node:fs'; // Import Node.js fs module
import path from 'node:path'; // Import Node.js path module
// Read and parse package.json manually
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
const pkg = JSON.parse(packageJsonContent);
export default {
input: 'src/index.ts', // Entry point
output: [
{
file: pkg.main, // dist/animus-sdk.umd.js
format: 'umd', // Universal Module Definition (works in script tags)
name: 'AnimusSDK', // Global variable name for UMD build
sourcemap: true,
},
{
file: pkg.module, // dist/animus-sdk.esm.js
format: 'esm', // ES Module (for modern bundlers/browsers)
sourcemap: true,
},
],
plugins: [
json(), // Add the json plugin here
resolve({ browser: true }), // Resolve node modules, prioritizing browser versions
commonjs(), // Convert CommonJS modules to ES6
typescript({
tsconfig: './tsconfig.json', // Point to your tsconfig file
sourceMap: true,
declaration: true, // Let the plugin handle declaration generation
declarationDir: 'dist/types',
}),
],
};