rollup.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2024 Puter Technologies Inc.
  3. *
  4. * This file is part of Puter's Terminal.
  5. *
  6. * Puter's Terminal is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import { nodeResolve } from '@rollup/plugin-node-resolve'
  20. import commonjs from '@rollup/plugin-commonjs';
  21. import copy from 'rollup-plugin-copy';
  22. const configFile = process.env.CONFIG_FILE ?? 'config/dev.js';
  23. await import(`./${configFile}`);
  24. export default {
  25. input: "src/main.js",
  26. output: {
  27. file: "dist/bundle.js",
  28. format: "iife"
  29. },
  30. plugins: [
  31. nodeResolve(),
  32. commonjs(),
  33. copy({
  34. targets: [
  35. {
  36. src: 'assets/index.html',
  37. dest: 'dist',
  38. transform: (contents, name) => {
  39. return contents.toString().replace('__SDK_URL__',
  40. process.env.PUTER_JS_URL ?? globalThis.__CONFIG__.sdk_url);
  41. }
  42. },
  43. { src: 'assets/shell.html', dest: 'dist' },
  44. { src: 'assets/normalize.css', dest: 'dist' },
  45. { src: 'assets/style.css', dest: 'dist' },
  46. { src: 'node_modules/xterm/css/xterm.css', dest: 'dist' },
  47. { src: configFile, dest: 'dist', rename: 'config.js' }
  48. ]
  49. }),
  50. ]
  51. }