rollup.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. 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_puter.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: configFile, dest: 'dist', rename: 'config.js' }
  49. ]
  50. }),
  51. ]
  52. }