-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
49 lines (47 loc) · 1.35 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
import fs from 'fs'
import path from 'path'
import replace from '@rollup/plugin-replace'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'
const jsonPath = path.resolve(__dirname, './package.json')
const jsonData = JSON.parse(fs.readFileSync(jsonPath, 'utf8'))
const isProduction = process.env.NODE_ENV === 'production'
export default {
input: 'src/index.ts',
context: 'globalThis',
external: (id) => /~system\//.test(id) || /@dcl\//.test(id),
output: [
{
exports: 'named',
file: jsonData.main,
format: 'es',
},
],
plugins: [
replace({
__VERSION__: JSON.stringify(jsonData.version),
preventAssignment: true,
}),
typescript({
tsconfig: './tsconfig.json',
sourceMap: false,
compilerOptions: {
declaration: true,
sourceMap: false,
inlineSourceMap: false,
inlineSources: false,
},
}),
commonjs({
ignoreGlobal: false,
}),
resolve({
preferBuiltins: true,
browser: true,
platform: 'node'
}),
isProduction && terser({ format: { comments: false } }),
].filter(Boolean), // This filters out the falsy values from the array
}