forked from react-pdf-viewer/react-pdf-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.cjs
41 lines (35 loc) · 1.07 KB
/
rollup.config.cjs
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
const json = require('@rollup/plugin-json');
const terser = require('@rollup/plugin-terser');
const typescript = require('@rollup/plugin-typescript');
const path = require('path');
const rootPackagePath = process.cwd();
const input = path.join(rootPackagePath, 'src/index.ts');
const pkg = require(path.join(rootPackagePath, 'package.json'));
const outputDir = path.join(rootPackagePath, 'lib');
const pgkName = pkg.name.split('/').pop();
const external = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})];
const plugins = [json(), typescript()];
module.exports = [
// CJS
{
input,
output: {
exports: 'named',
file: path.join(outputDir, `cjs/${pgkName}.js`),
format: 'cjs',
},
external,
plugins,
},
// Minified CJS
{
input,
output: {
exports: 'named',
file: path.join(outputDir, `cjs/${pgkName}.min.js`),
format: 'cjs',
},
external,
plugins: plugins.concat([terser()]),
},
];