]> git.openstreetmap.org Git - nominatim-ui.git/blob - rollup.config.js
validate hidden fields against pattern only when filled
[nominatim-ui.git] / rollup.config.js
1 import svelte from 'rollup-plugin-svelte';
2 import commonjs from '@rollup/plugin-commonjs';
3 import resolve from '@rollup/plugin-node-resolve';
4 import livereload from 'rollup-plugin-livereload';
5 import { terser } from 'rollup-plugin-terser';
6 import css from 'rollup-plugin-css-only';
7
8 const production = !process.env.ROLLUP_WATCH;
9
10 function serve() {
11         let server;
12
13         function toExit() {
14                 if (server) server.kill(0);
15         }
16
17         return {
18                 writeBundle() {
19                         if (server) return;
20                         server = require('child_process').spawn('yarn', ['start', '-d'], {
21                                 stdio: ['ignore', 'inherit', 'inherit'],
22                                 shell: true
23                         });
24
25                         process.on('SIGTERM', toExit);
26                         process.on('exit', toExit);
27                 }
28         };
29 }
30
31 export default {
32         input: 'src/main.js',
33         output: {
34                 sourcemap: true,
35                 format: 'iife',
36                 name: 'app',
37                 file: 'dist/build/bundle.js'
38         },
39         plugins: [
40                 svelte({
41                         compilerOptions: {
42                                 // enable run-time checks when not in production
43                                 dev: !production
44                         }
45                 }),
46                 // we'll extract any component CSS out into
47                 // a separate file - better for performance
48                 css({ output: 'bundle.css' }),
49
50                 // If you have external dependencies installed from
51                 // npm, you'll most likely need these plugins. In
52                 // some cases you'll need additional configuration -
53                 // consult the documentation for details:
54                 // https://github.com/rollup/plugins/tree/master/packages/commonjs
55                 resolve({
56                         browser: true,
57                         dedupe: ['svelte']
58                 }),
59                 commonjs(),
60
61                 // In dev mode, call `npm run start` once
62                 // the bundle has been generated
63                 !production && serve(),
64
65                 // Watch the `dist` directory and refresh the
66                 // browser on changes when not in production
67                 !production && livereload('dist'),
68
69                 // If we're building for production (npm run build
70                 // instead of npm run dev), minify
71                 production && terser()
72         ],
73         watch: {
74                 clearScreen: false
75         }
76 };