forked from josdejong/svelte-jsoneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.bundle.js
More file actions
62 lines (54 loc) · 1.64 KB
/
Copy pathrollup.config.bundle.js
File metadata and controls
62 lines (54 loc) · 1.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import path from 'path'
import fs from 'fs'
import svelte from 'rollup-plugin-svelte'
import { terser } from 'rollup-plugin-terser'
import sveltePreprocess from 'svelte-preprocess'
import pkg from './package.json'
import { addBundleExports } from './tools/addBundleExports.js'
import { createDefinitionsFile } from './tools/createDefinitionsFile.js'
const production = !process.env.ROLLUP_WATCH
const packageFolder = 'package'
const file = path.join(packageFolder, pkg.module)
const sourcemapFile = file + '.map'
const definitionsFile = file.replace(/\.js$/, '.d.ts')
fs.mkdirSync(path.dirname(file))
createDefinitionsFile(definitionsFile)
addBundleExports(packageFolder, file, sourcemapFile, definitionsFile)
export default {
input: 'src/lib/index.ts',
output: [
{
file,
format: 'es',
sourcemap: false, // FIXME: enable sourcemap (generated source map has issues right now)
inlineDynamicImports: true
}
],
plugins: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production
},
// we want to embed the CSS in the generated JS bundle
emitCss: false,
preprocess: sveltePreprocess()
}),
resolve({
browser: true
}),
commonjs(),
json(),
typescript(),
getBabelOutputPlugin({
presets: ['@babel/preset-env']
}),
// minify
production && terser()
]
}