summaryrefslogtreecommitdiff
path: root/packages/backend/rollup.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/rollup.config.js')
-rw-r--r--packages/backend/rollup.config.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/packages/backend/rollup.config.js b/packages/backend/rollup.config.js
new file mode 100644
index 0000000..9051adc
--- /dev/null
+++ b/packages/backend/rollup.config.js
@@ -0,0 +1,100 @@
+/*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+// rollup.config.js
+import linaria from '@linaria/rollup';
+import nodeResolve from "@rollup/plugin-node-resolve";
+import alias from "@rollup/plugin-alias";
+import image from '@rollup/plugin-image';
+import json from "@rollup/plugin-json";
+import ts from "@rollup/plugin-typescript";
+import replace from "@rollup/plugin-replace";
+import css from 'rollup-plugin-css-only';
+import html from '@rollup/plugin-html';
+
+
+
+const template = async ({
+ files,
+ title
+}) => {
+ const scripts = (files.js || []).map(({ code }) => `<script>${code}</script>`).join('\n');
+ const css = (files.css || []).map(({ source }) => `<style>${source}</style>`).join('\n');
+ return `
+<!doctype html>
+<html>
+ <head>
+ <title>${title}</title>
+ ${css}
+ </head>
+ <body>
+ ${scripts}
+ <script>page.mountIntoBody()</script>
+ </body>
+</html>`;
+};
+
+const makePlugins = (name) => [
+ alias({
+ entries: [
+ { find: 'react', replacement: 'preact/compat' },
+ { find: 'react-dom', replacement: 'preact/compat' }
+ ]
+ }),
+
+ replace({
+ "process.env.NODE_ENV": JSON.stringify("production"),
+ preventAssignment: true,
+ }),
+
+ nodeResolve({
+ browser: true,
+ preferBuiltins: true,
+ }),
+
+ json(),
+ image(),
+
+ linaria({
+ sourceMap: process.env.NODE_ENV !== 'production',
+ }),
+ css(),
+ ts({
+ sourceMap: false,
+ outputToFilesystem: false,
+ }),
+ html({ template, fileName: name }),
+];
+
+
+const pageDefinition = (name) => ({
+ input: `src/pages/${name}.tsx`,
+ output: {
+ file: `dist/pages/${name}.js`,
+ format: "iife",
+ exports: 'named',
+ name: 'page',
+ },
+ plugins: makePlugins(`${name}.html`),
+});
+
+export default [
+ pageDefinition("OfferTip"),
+ pageDefinition("OfferRefund"),
+ pageDefinition("DepletedTip"),
+ pageDefinition("RequestPayment"),
+ pageDefinition("ShowOrderDetails"),
+]