-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
85 lines (82 loc) · 1.96 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
import svelte from "rollup-plugin-svelte";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import postcss from 'rollup-plugin-postcss'
import aliasPlugin from '@rollup/plugin-alias';
import { terser } from "rollup-plugin-terser";
import md from 'rollup-plugin-md';
const isDev = Boolean(process.env.ROLLUP_WATCH);
const dedupe = importee => importee === 'svelte' || importee.startsWith('svelte/');
const alias = aliasPlugin({
resolve: ['.svelte', '.js'], //optional, by default this will just look for .js files or folders
entries: [
{ find: 'components', replacement: 'src/components' },
{ find: 'routes', replacement: 'src/routes' },
{ find: 'util', replacement: 'src/util' },
]
});
export default [
// Browser bundle
{
input: "src/main.js",
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/bundle.js"
},
plugins: [
svelte({
hydratable: true,
css: css => {
css.write("public/bundle.css");
}
}),
resolve({
browser: true,
dedupe
}),
commonjs(),
// App.js will be built after bundle.js, so we only need to watch that.
// By setting a small delay the Node server has a chance to restart before reloading.
isDev &&
livereload({
watch: "public/App.js",
delay: 200
}),
!isDev && terser(),
md({
marked: {
//marked options
}
}),
postcss({
plugins: []
}),
alias
]
},
// Server bundle
{
input: "src/App.svelte",
output: {
sourcemap: false,
format: "cjs",
name: "app",
file: "public/App.js"
},
plugins: [
svelte({
generate: "ssr",
}),
resolve(),
commonjs(),
!isDev && terser(),
postcss({
plugins: []
}),
alias
]
}
];