-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
74 lines (66 loc) · 1.87 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
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 { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
import babel from 'rollup-plugin-babel';
const ie11Build = process.env.PAP_LEGACY_BUILD;
const production = !process.env.ROLLUP_WATCH;
const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, m => m.toUpperCase())
.replace(/-\w/g, m => m[1].toUpperCase());
const prodOutput = [];
if (ie11Build) {
prodOutput.push({ file: 'dist/pick-a-place-legacy.min.js', format: 'iife', name });
} else {
prodOutput.push(
{ file: 'dist/index.min.mjs', format: 'es' },
{ file: 'dist/index.min.js', format: 'umd', name },
{ file: 'dist/pick-a-place.min.js', format: 'iife', name }
);
}
export default {
input: !production ? 'src/main.js' : 'src/components/components.module.js',
output: !production
? {
sourcemap: true,
format: 'iife',
name: name,
file: 'public/bundle.js'
}
: prodOutput,
plugins: [
svelte({
dev: !production,
css: css => {
production ? css.write('dist/pick-a-place.css') : css.write('public/bundle.css');
}
}),
resolve(),
commonjs(),
!production && livereload('public'),
ie11Build &&
babel({
extensions: ['.js', '.mjs', '.html', '.svelte'],
runtimeHelpers: true,
exclude: ['node_modules/@babel/**', 'node_modules/core-js/**'],
presets: [
[
'@babel/preset-env',
{
targets: '> 1.5%, IE 11, not dead',
useBuiltIns: 'usage',
corejs: 3
}
]
],
plugins: []
}),
production && terser()
],
watch: {
clearScreen: false
}
};