-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
81 lines (79 loc) · 2.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import svelte from 'rollup-plugin-svelte'
import terser from '@rollup/plugin-terser'
import sveltePreprocess from 'svelte-preprocess'
import alias from '@rollup/plugin-alias';
import image from '@rollup/plugin-image';
import cssAutoprefixer from 'autoprefixer';
import cssImport from 'postcss-import';
import cssImportUrl from 'postcss-import-url';
import cssVariables from 'postcss-css-variables';
import cssRemoveRoot from 'postcss-remove-root';
import postcss from 'rollup-plugin-postcss';
import path from 'path';
const production = process.env.NODE_ENV !== 'dev';
export default [{
// The file that creates all web components.
input: 'src/web-components.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
// Output it to public. This way, the SvelteKit
// app will also host the web components.
file: 'package/web-components.min.js',
},
watch: !production,
plugins: [
typescript({
sourceMap: true,
}),
svelte({
preprocess: sveltePreprocess({
sourceMap: true,
postcss: {
plugins: [cssImport({ plugins: [cssImportUrl()] }), cssImportUrl(), cssVariables(), cssRemoveRoot(), cssAutoprefixer()]
}
}),
// Make sure that no global CSS is injeced
// into the page that imports this script.
emitCss: false,
}),
resolve(),
postcss({
minify: production,
include: [path.resolve('src/fonts.css')],
extract: path.resolve('package/web-components-fonts.css'),
plugins: [cssImport(), cssImportUrl()]
}),
commonjs(),
alias({
entries: [
{ find: '$lib', replacement: 'src/lib' }
]
}),
image(),
// Minify the build
production && terser(),
],
},
{
input: 'src/web-components-metadata.ts',
output: {
sourcemap: true,
format: 'es',
name: 'app',
file: 'package/web-components-metadata.min.js',
},
watch: !production,
plugins: [
typescript({
sourceMap: true,
}),
resolve(),
commonjs(),
production && terser(),
],
}]