svelte_menu/rollup.config.js

82 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2020-04-08 21:27:58 +00:00
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
2022-07-18 10:26:47 +00:00
import resolve from '@rollup/plugin-node-resolve';
2020-04-08 21:27:58 +00:00
import livereload from 'rollup-plugin-livereload';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
2022-07-18 10:26:47 +00:00
import css from 'rollup-plugin-css-only';
2020-04-08 21:27:58 +00:00
const production = !process.env.ROLLUP_WATCH;
2022-07-18 10:26:47 +00:00
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
'stdio': ['ignore', 'inherit', 'inherit'],
'shell': true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}
2020-04-08 21:27:58 +00:00
export default {
2020-05-10 11:07:00 +00:00
'input': 'src/main.js',
'output': {
2022-07-18 10:26:47 +00:00
'sourcemap': true,
2020-05-10 11:07:00 +00:00
'format': 'iife',
'name': 'app',
'file': 'public/build/bundle.js'
},
'plugins': [
svelte({
2022-07-18 10:26:47 +00:00
'compilerOptions': {
// enable run-time checks when not in production
'dev': !production
2020-05-10 11:07:00 +00:00
}
}),
2022-07-18 10:26:47 +00:00
// we'll extract any component CSS out into
// a separate file - better for performance
css({ 'output': 'bundle.css' }),
2020-04-08 21:27:58 +00:00
2020-05-10 11:07:00 +00:00
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
'browser': true,
'dedupe': ['svelte']
}),
commonjs(),
replace({
'exclude': 'node_modules/**',
'ENV': JSON.stringify(production ? 'production' : 'development')
}),
2020-04-08 21:27:58 +00:00
2020-05-10 11:07:00 +00:00
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
2020-04-08 21:27:58 +00:00
2020-05-10 11:07:00 +00:00
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
2020-04-08 21:27:58 +00:00
2020-05-10 11:07:00 +00:00
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
'watch': {
'clearScreen': false
}
2020-04-08 21:27:58 +00:00
};