Advertisement
Guest User

Untitled

a guest
Nov 30th, 2020
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  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. import sveltePreprocess from 'svelte-preprocess';
  7. import typescript from '@rollup/plugin-typescript';
  8. import alias from "@rollup/plugin-alias";
  9. import path from "path";
  10. // import css from "rollup-plugin-css-only";
  11.  
  12. const production = process.env.NODE_ENV === "production";
  13.  
  14. const customResolver = resolve({
  15. extensions: [".ts", ".svelte"]
  16. });
  17.  
  18. export default {
  19. input: path.resolve(__dirname, "src/main.ts"),
  20. output: {
  21. sourcemap: true,
  22. format: 'iife',
  23. name: 'app',
  24. file: path.resolve(__dirname, "public/build/bundle.js")
  25. },
  26. onwarn: (message, warn) => {
  27. if (message.code === "CIRCULAR_DEPENDENCY") {
  28. return;
  29. }
  30. warn(message);
  31. },
  32. plugins: [
  33. alias({
  34. entries: [
  35. { find: "@src", replacement: path.resolve(__dirname, "src") },
  36. ],
  37. customResolver
  38. }),
  39. svelte({
  40. // enable run-time checks when not in production
  41. dev: !production,
  42. // we'll extract any component CSS out into
  43. // a separate file - better for performance
  44. preprocess: sveltePreprocess({
  45. aliases: ['ts', 'typescript']
  46. }),
  47. }),
  48. // css({ output: path.resolve(__dirname, "public/build/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. typescript({
  61. sourceMap: !production,
  62. tsconfig: path.resolve(__dirname, "tsconfig.json"),
  63. }),
  64.  
  65. // In dev mode, call `npm run start` once
  66. // the bundle has been generated
  67. // !production && serve(),
  68.  
  69. // Watch the `public` directory and refresh the
  70. // browser on changes when not in production
  71. // !production && livereload('public'),
  72.  
  73. // If we're building for production (npm run build
  74. // instead of npm run dev), minify
  75. production && terser()
  76. ],
  77. watch: {
  78. clearScreen: false
  79. }
  80. };
  81.  
  82. // function serve() {
  83. // let started = false;
  84.  
  85. // return {
  86. // writeBundle() {
  87. // if (!started) {
  88. // started = true;
  89.  
  90. // require('child_process').spawn('npm', ['run', 'dev'], {
  91. // stdio: ['ignore', 'inherit', 'inherit'],
  92. // shell: true
  93. // });
  94. // }
  95. // }
  96. // };
  97. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement