web: write interfaces to different folders and remove custom chunk names

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-10 17:54:50 +01:00
parent 202b057ce9
commit 1e8d45dc15
4 changed files with 28 additions and 60 deletions

View file

@ -4,7 +4,7 @@
{% load i18n %} {% load i18n %}
{% block head %} {% block head %}
<script src="{% static 'dist/AdminInterface.js' %}" type="module"></script> <script src="{% static 'dist/admin/AdminInterface.js' %}" type="module"></script>
{% endblock %} {% endblock %}
{% block body %} {% block body %}

View file

@ -11,7 +11,7 @@
{% endblock %} {% endblock %}
{% block head %} {% block head %}
<script src="{% static 'dist/FlowInterface.js' %}" type="module"></script> <script src="{% static 'dist/flow/FlowInterface.js' %}" type="module"></script>
<style> <style>
.pf-c-background-image::before { .pf-c-background-image::before {
--ak-flow-background: url("{{ flow.background_url }}"); --ak-flow-background: url("{{ flow.background_url }}");

View file

@ -4,7 +4,7 @@
{% load i18n %} {% load i18n %}
{% block head %} {% block head %}
<script src="{% static 'dist/UserInterface.js' %}" type="module"></script> <script src="{% static 'dist/user/UserInterface.js' %}" type="module"></script>
{% endblock %} {% endblock %}
{% block body %} {% block body %}

View file

@ -46,6 +46,7 @@ const resources = [
const isProdBuild = process.env.NODE_ENV === "production"; const isProdBuild = process.env.NODE_ENV === "production";
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const apiBasePath = process.env.AK_API_BASE_PATH || ""; const apiBasePath = process.env.AK_API_BASE_PATH || "";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function manualChunks(id) { function manualChunks(id) {
if (id.includes("@goauthentik/api")) { if (id.includes("@goauthentik/api")) {
@ -64,6 +65,24 @@ function manualChunks(id) {
} }
} }
const PLUGINS = [
cssimport(),
nodeResolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: "runtime",
include: ["src/**/*"],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
"preventAssignment": true,
}),
sourcemaps(),
isProdBuild && terser(),
].filter((p) => p);
export default [ export default [
// Polyfills (imported first) // Polyfills (imported first)
{ {
@ -96,29 +115,12 @@ export default [
output: [ output: [
{ {
format: "es", format: "es",
dir: "dist", dir: "dist/flow",
sourcemap: true, sourcemap: true,
manualChunks: manualChunks, manualChunks: manualChunks,
chunkFileNames: "flow-[name].js",
}, },
], ],
plugins: [ plugins: PLUGINS,
cssimport(),
nodeResolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: "runtime",
include: ["src/**/*"],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
"preventAssignment": true,
}),
sourcemaps(),
isProdBuild && terser(),
].filter((p) => p),
watch: { watch: {
clearScreen: false, clearScreen: false,
}, },
@ -130,29 +132,12 @@ export default [
output: [ output: [
{ {
format: "es", format: "es",
dir: "dist", dir: "dist/admin",
sourcemap: true, sourcemap: true,
manualChunks: manualChunks, manualChunks: manualChunks,
chunkFileNames: "admin-[name].js",
}, },
], ],
plugins: [ plugins: PLUGINS,
cssimport(),
nodeResolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: "runtime",
include: ["src/**/*"],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
"preventAssignment": true,
}),
sourcemaps(),
isProdBuild && terser(),
].filter((p) => p),
watch: { watch: {
clearScreen: false, clearScreen: false,
}, },
@ -164,29 +149,12 @@ export default [
output: [ output: [
{ {
format: "es", format: "es",
dir: "dist", dir: "dist/user",
sourcemap: true, sourcemap: true,
manualChunks: manualChunks, manualChunks: manualChunks,
chunkFileNames: "user-[name].js",
}, },
], ],
plugins: [ plugins: PLUGINS,
cssimport(),
nodeResolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: "runtime",
include: ["src/**/*"],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
"preventAssignment": true,
}),
sourcemaps(),
isProdBuild && terser(),
].filter((p) => p),
watch: { watch: {
clearScreen: false, clearScreen: false,
}, },