rollup.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. const production = !process.env.ROLLUP_WATCH;
  7. export default {
  8. input: 'src/main.js',
  9. output: {
  10. sourcemap: true,
  11. format: 'iife',
  12. name: 'app',
  13. file: 'public/bundle.js'
  14. },
  15. plugins: [
  16. svelte({
  17. // enable run-time checks when not in production
  18. dev: !production,
  19. // we'll extract any component CSS out into
  20. // a separate file  better for performance
  21. css: css => {
  22. css.write('public/bundle.css');
  23. }
  24. }),
  25. // If you have external dependencies installed from
  26. // npm, you'll most likely need these plugins. In
  27. // some cases you'll need additional configuration 
  28. // consult the documentation for details:
  29. // https://github.com/rollup/rollup-plugin-commonjs
  30. resolve({
  31. browser: true,
  32. dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
  33. }),
  34. commonjs(),
  35. // Watch the `public` directory and refresh the
  36. // browser on changes when not in production
  37. !production && livereload('public'),
  38. // If we're building for production (npm run build
  39. // instead of npm run dev), minify
  40. production && terser()
  41. ],
  42. watch: {
  43. clearScreen: false
  44. }
  45. };