-
Notifications
You must be signed in to change notification settings - Fork 112
/
rollup.config.vanilla-library.js
67 lines (58 loc) · 1.97 KB
/
rollup.config.vanilla-library.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
56
57
58
59
60
61
62
63
64
65
66
67
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 postcss from 'rollup-plugin-postcss'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import path from 'path'
import svelte from 'rollup-plugin-svelte'
import terser from '@rollup/plugin-terser'
import { sveltePreprocess } from 'svelte-preprocess'
import { getVanillaDependencies } from './tools/getExternalDependencies.js'
const production = !process.env.ROLLUP_WATCH
const packageFolder = 'package-vanilla'
const file = path.join(packageFolder, 'index.js')
export default {
input: 'src/lib/index-vanilla.ts',
external: getVanillaDependencies(),
output: [
{
file,
format: 'es',
sourcemap: true,
inlineDynamicImports: true
}
],
plugins: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production
},
emitCss: true,
preprocess: sveltePreprocess()
}),
postcss({
plugins: []
}),
resolve({
browser: true,
exportConditions: ['svelte']
}),
commonjs(),
json(),
typescript({ sourceMap: true, inlineSources: true }),
getBabelOutputPlugin({
// { modules: false } is to resolve the following console warning:
// Dynamic import can only be transformed when transforming ES modules to AMD, CommonJS or SystemJS.
// See: https://stackoverflow.com/questions/63563485/how-can-i-preserve-dynamic-import-statements-with-babel-preset-env
presets: [['@babel/preset-env', { modules: false }]],
// { compact: true } is to resolve the following console warning:
// [BABEL] Note: The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB.
// See: https://github.com/babel/babel/discussions/13676
compact: true
}),
// minify
production && terser()
]
}