You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rollup.config.js 1.8KB

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