forked from fielding/svelte-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
85 lines (72 loc) · 1.79 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 replace from '@rollup/plugin-replace';
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
const { resolve: rslv } = require('path');
const config = require('./svelte.config');
const production = !process.env.ROLLUP_WATCH;
console.log('Environment:\n', {
NODE_ENV: JSON.stringify(production ? 'production' : 'development'),
}, '\n');
export default {
input: 'src/index.ts',
output: {
name: 'app',
format: 'esm',
sourcemap: true,
dir: 'public',
},
plugins: [
svelte({
...config,
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write('public/bundle.css');
}
}),
replace({
NODE_ENV: JSON.stringify(production ? 'production' : 'development')
}),
alias({
resolve: ['.ts', '.svelte', '.js'],
entries: [
{
find:'~',
replacement: rslv('src')
},
],
}),
resolve({
extensions: ['.ts', '.svelte', '.mjs', '.js'],
dedupe: importee => importee === 'svelte' || /^svelte/i.test(importee),
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
cacheRoot : '.tscache',
tsconfigOverride: {
compilerOptions: {
watch: !production,
sourceMap: !production
}
},
}),
!production && livereload({
watch: 'public',
port: 35730, // use non-default port to avoid conflict with sdk
}),
production && terser({
output: { comments: false },
}),
],
watch: {
clearScreen: false
}
};