From b58875d4c7f67f437209948a7890f4760b469de9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 26 Nov 2021 14:18:51 +0100 Subject: [PATCH] web: add rollup config for proxy outpost Signed-off-by: Jens Langhammer --- proxy.Dockerfile | 2 +- web/package.json | 1 + web/rollup.config.js | 58 +++++++++++++++++++++++--------------------- web/rollup.proxy.js | 3 +++ 4 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 web/rollup.proxy.js diff --git a/proxy.Dockerfile b/proxy.Dockerfile index f60f7e8d9..1c4c76a07 100644 --- a/proxy.Dockerfile +++ b/proxy.Dockerfile @@ -4,7 +4,7 @@ FROM --platform=${BUILDPLATFORM} docker.io/node:16 as web-builder COPY ./web /static/ ENV NODE_ENV=production -RUN cd /static && npm i && npm run build +RUN cd /static && npm i && npm run build-proxy # Stage 2: Build FROM docker.io/golang:1.17.3-bullseye AS builder diff --git a/web/package.json b/web/package.json index 569a90f22..43619df52 100644 --- a/web/package.json +++ b/web/package.json @@ -6,6 +6,7 @@ "scripts": { "extract": "lingui extract", "build": "lingui compile && rollup -c ./rollup.config.js", + "build-proxy": "lingui compile && rollup -c ./rollup.proxy.js", "watch": "lingui compile && rollup -c -w", "lint": "eslint . --max-warnings 0 --fix", "lit-analyse": "lit-analyzer src", diff --git a/web/rollup.config.js b/web/rollup.config.js index e26693640..3b1d431b3 100644 --- a/web/rollup.config.js +++ b/web/rollup.config.js @@ -10,7 +10,7 @@ import { terser } from "rollup-plugin-terser"; const extensions = [".js", ".jsx", ".ts", ".tsx"]; -const resources = [ +export const resources = [ { src: "node_modules/rapidoc/dist/rapidoc-min.js", dest: "dist/" }, { @@ -44,12 +44,12 @@ const resources = [ ]; // eslint-disable-next-line no-undef -const isProdBuild = process.env.NODE_ENV === "production"; +export const isProdBuild = process.env.NODE_ENV === "production"; // eslint-disable-next-line no-undef -const apiBasePath = process.env.AK_API_BASE_PATH || ""; +export const apiBasePath = process.env.AK_API_BASE_PATH || ""; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -function manualChunks(id) { +export function manualChunks(id) { if (id.endsWith(".md")) { return "docs"; } @@ -69,7 +69,7 @@ function manualChunks(id) { } } -const PLUGINS = [ +export const PLUGINS = [ cssimport(), markdown(), nodeResolve({ extensions, browser: true }), @@ -88,31 +88,33 @@ const PLUGINS = [ isProdBuild && terser(), ].filter((p) => p); -export default [ - // Polyfills (imported first) - { - input: "./poly.ts", - output: [ - { - format: "iife", - file: "dist/poly.js", - sourcemap: true, - }, - ], - plugins: [ - cssimport(), - nodeResolve({ browser: true }), - commonjs(), - isProdBuild && terser(), - copy({ - targets: [...resources], - copyOnce: false, - }), - ].filter((p) => p), - watch: { - clearScreen: false, +// Polyfills (imported first) +export const POLY = { + input: "./poly.ts", + output: [ + { + format: "iife", + file: "dist/poly.js", + sourcemap: true, }, + ], + plugins: [ + cssimport(), + nodeResolve({ browser: true }), + commonjs(), + isProdBuild && terser(), + copy({ + targets: [...resources], + copyOnce: false, + }), + ].filter((p) => p), + watch: { + clearScreen: false, }, +}; + +export default [ + POLY, // Flow interface { input: "./src/interfaces/FlowInterface.ts", diff --git a/web/rollup.proxy.js b/web/rollup.proxy.js new file mode 100644 index 000000000..d0e3f4aee --- /dev/null +++ b/web/rollup.proxy.js @@ -0,0 +1,3 @@ +import { POLY } from "./rollup.config"; + +export default [POLY];