rollup.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2024 Puter Technologies Inc.
  3. *
  4. * This file is part of Phoenix Shell.
  5. *
  6. * Phoenix Shell 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. const configFile = process.env.CONFIG_FILE ?? 'config/dev.js';
  24. await import(`./${configFile}`);
  25. export default {
  26. input: "src/main_puter.js",
  27. output: {
  28. file: "dist/bundle.js",
  29. format: "iife"
  30. },
  31. plugins: [
  32. nodeResolve(),
  33. commonjs(),
  34. copy({
  35. targets: [
  36. {
  37. src: 'assets/index.html',
  38. dest: 'dist',
  39. transform: (contents, name) => {
  40. return contents.toString().replace('__SDK_URL__',
  41. process.env.PUTER_JS_URL ?? globalThis.__CONFIG__.sdk_url);
  42. }
  43. },
  44. { src: 'assets/shell.html', dest: 'dist' },
  45. { src: configFile, dest: 'dist', rename: 'config.js' }
  46. ]
  47. }),
  48. ]
  49. }