txtodo.app

[DORMANT] the official website of txtodo
git clone git://git.figbert.com/txtodo.app.git
Log | Files | Refs | README | LICENSE

rollup.config.js (1003B)


      1 import svelte from 'rollup-plugin-svelte';
      2 import resolve from '@rollup/plugin-node-resolve';
      3 import commonjs from '@rollup/plugin-commonjs';
      4 import livereload from 'rollup-plugin-livereload';
      5 import { terser } from 'rollup-plugin-terser';
      6 
      7 const production = !process.env.ROLLUP_WATCH;
      8 
      9 export default {
     10 	input: 'src/main.js',
     11 	output: {
     12 		sourcemap: true,
     13 		format: 'iife',
     14 		name: 'app',
     15 		file: 'public/build/bundle.js'
     16 	},
     17 	plugins: [
     18 		svelte({
     19             compilerOptions: {
     20 			    dev: !production
     21             }
     22 		}),
     23 		resolve({
     24 			browser: true,
     25 			dedupe: ['svelte']
     26 		}),
     27 		commonjs(),
     28 		!production && serve(),
     29 		!production && livereload('public'),
     30 		production && terser()
     31 	],
     32 	watch: {
     33 		clearScreen: false
     34 	}
     35 };
     36 
     37 function serve() {
     38 	let started = false;
     39 
     40 	return {
     41 		writeBundle() {
     42 			if (!started) {
     43 				started = true;
     44 
     45 				require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
     46 					stdio: ['ignore', 'inherit', 'inherit'],
     47 					shell: true
     48 				});
     49 			}
     50 		}
     51 	};
     52 }