This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
55 lines (53 loc) · 1.91 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
/* eslint-disable no-underscore-dangle */
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf8'));
export default {
input: 'src/index.ts', // your main TypeScript file
output: [
{
file: 'dist/bundle.cjs.js', // output bundle location for CommonJS
format: 'cjs', // CommonJS format for Node.js
sourcemap: process.env.BUILD_DEV === 'true', // Conditionally generate sourcemaps
},
{
file: 'dist/bundle.esm.js', // output bundle location for ESM
format: 'esm', // ES Module format for import
sourcemap: process.env.BUILD_DEV === 'true', // Conditionally generate sourcemaps
},
{
file: 'dist/bundle.iife.js', // output bundle location for IIFE
format: 'iife', // Immediately-invoked Function Expression — suitable for <script> tags
name: 'Nucleus',
sourcemap: process.env.BUILD_DEV === 'true', // Conditionally generate sourcemaps
},
],
plugins: [
typescript({
// this option enables use of the declarations directory defined in tsconfig.json
useTsconfigDeclarationDir: true,
// this enables generation of declaration files and specifies the output directory
tsconfigOverride: {
compilerOptions: {
declaration: true,
declarationDir: './dist/types',
},
},
}),
resolve(),
commonjs(),
replace({
preventAssignment: true, // This is required since rollup plugin replace v3.0.0
values: {
__VERSION__: JSON.stringify(pkg.version),
},
}),
],
};