-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
86 lines (82 loc) · 2.07 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
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from "rollup-plugin-terser";
import { babel } from '@rollup/plugin-babel';
import sveltePreprocess from 'svelte-preprocess'
import css from 'rollup-plugin-css-only'
import csso from 'postcss-csso';
const production = !process.env.ROLLUP_WATCH
const buildType = typeof process.env.ROLLUP_BUILD_TYPE !== "undefined" ? process.env.ROLLUP_BUILD_TYPE : "modern";
export default {
input: 'src/js/main.js',
output: {
sourcemap: (production ? false : 'inline'),
format: 'iife',
name: 'app',
dir: 'assets/frontend',
entryFileNames: (buildType === "modern" ? "js/main.js" : "js/legacy.js"),
globals: {
'svelte-focus-trap': 'svelteFocusTrap'
}
},
plugins: [
svelte({
compilerOptions: {
dev: !production,
},
preprocess: sveltePreprocess({
sourceMap: !production,
postcss: {
plugins: [
require('autoprefixer')(),
csso({
restructure: true,
forceMediaMerge: true,
comments: false
})
]
}
}),
}),
css({ output: 'css/main.css' }),
resolve(),
commonjs(),
(buildType === "legacy") && babel({
extensions: [ '.js', '.html', '.svelte' ],
babelHelpers: 'runtime',
exclude: [ 'node_modules/@babel/**', 'node_modules/core-js/**' ],
presets: [
[
'@babel/preset-env',
{
targets: {
ie: '11'
},
useBuiltIns: 'usage',
corejs: 3
}
]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
useESModules: true
}
]
]
}),
production && terser({
ecma: buildType === "legacy" ? 5 : 2017,
safari10: true,
format: {
comments: false
}
})
],
watch: {
clearScreen: false
}
}