rollup.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.js",
  27. output: {
  28. file: "dist/bundle.js",
  29. format: "iife"
  30. },
  31. plugins: [
  32. nodeResolve({
  33. browser: true,
  34. preferBuiltins: false,
  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: configFile, dest: 'dist', rename: 'config.js' }
  48. ]
  49. }),
  50. ]
  51. }