rollup.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. import process from 'node:process';
  23. import path from 'node:path';
  24. const configFile = process.env.CONFIG_FILE ?? 'config/dev.js';
  25. await import(`./${configFile}`);
  26. export default {
  27. input: "src/main.js",
  28. output: {
  29. file: "dist/bundle.js",
  30. format: "iife"
  31. },
  32. plugins: [
  33. nodeResolve({
  34. rootDir: path.join(process.cwd(), '..'),
  35. }),
  36. commonjs(),
  37. copy({
  38. targets: [
  39. {
  40. src: 'assets/index.html',
  41. dest: 'dist',
  42. transform: (contents, name) => {
  43. return contents.toString().replace('__SDK_URL__',
  44. process.env.PUTER_JS_URL ?? globalThis.__CONFIG__.sdk_url);
  45. }
  46. },
  47. { src: 'assets/shell.html', dest: 'dist' },
  48. { src: 'assets/normalize.css', dest: 'dist' },
  49. { src: 'assets/style.css', dest: 'dist' },
  50. // We add this manually because there's no way to be sure
  51. // _which_ node_modules directory is the correct one, since
  52. // support for workspaces is under-documented and people may
  53. // be using package managers other than npm.
  54. { src: 'assets/xterm.css', dest: 'dist' },
  55. // { src: 'node_modules/xterm/css/xterm.css', dest: 'dist' },
  56. { src: configFile, dest: 'dist', rename: 'config.js' }
  57. ]
  58. }),
  59. ]
  60. }