-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
100 lines (97 loc) · 2.47 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import buble from 'rollup-plugin-buble';
import uglify from 'rollup-plugin-uglify';
import sass from 'rollup-plugin-sass';
import purifycss from 'purify-css';
import pkg from './package.json';
const production = !process.env.ROLLUP_WATCH;
export default [
{ // Rollup the Svelte client
input: 'client/app/main.js',
output: {
sourcemap: true,
format: 'iife',
file: 'public/bundle-app.js',
name: 'app',
},
plugins: [
svelte({
dev: !production,
css: (css) => {
css.write('public/bundle-app.css');
},
store: true,
cascade: false,
}),
resolve(),
commonjs(),
replace({ 'process.env.NODE_ENV': '"production"' }),
production && buble({ exclude: 'node_modules/**' }),
production && uglify(),
],
watch: {
include: 'client/app/**',
},
},
{ // Rollup the Widget
input: 'client/widget/main.js',
output: {
sourcemap: true,
format: 'iife',
file: 'public/bundle-widget.js',
name: 'widget',
},
plugins: [
svelte({
dev: !production,
css: (css) => {
css.write('public/bundle-widget.css');
},
store: false,
cascade: false,
}),
resolve(),
commonjs(),
replace({ 'process.env.NODE_ENV': '"production"' }),
production && buble({ exclude: 'node_modules/**' }),
production && uglify(),
],
watch: {
include: 'client/widget/**',
},
},
{ // Rollup the Express server
input: './server/main.js',
output: {
sourcemap: true,
format: 'cjs',
file: 'server.js',
},
plugins: [
resolve(),
commonjs(),
production && replace({ 'process.env.NODE_ENV': '"production"' }),
],
external: id => id in pkg.dependencies || id === 'crypto' || id === 'fs' || id === 'path',
watch: {
include: 'server/**',
},
},
{ // Bundle main CSS
input: 'client/main.scss',
output: { format: 'es', file: '/dev/null' }, // This doesn't matter
plugins: [
sass({
options: { precision: 6 },
processor: css => purifycss(['client/**/*.html'], css, { minify: production }),
output: 'public/bundle-main.css',
}),
],
watch: {
include: 'client/**',
},
},
];