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 %}
{% block head %}
<script src="{% static 'dist/AdminInterface.js' %}" type="module"></script>
<script src="{% static 'dist/admin/AdminInterface.js' %}" type="module"></script>
{% endblock %}
{% block body %}

View File

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

View File

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

View File

@ -46,6 +46,7 @@ const resources = [
const isProdBuild = process.env.NODE_ENV === "production";
// eslint-disable-next-line no-undef
const apiBasePath = process.env.AK_API_BASE_PATH || "";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function manualChunks(id) {
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 [
// Polyfills (imported first)
{
@ -96,29 +115,12 @@ export default [
output: [
{
format: "es",
dir: "dist",
dir: "dist/flow",
sourcemap: true,
manualChunks: manualChunks,
chunkFileNames: "flow-[name].js",
},
],
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),
plugins: PLUGINS,
watch: {
clearScreen: false,
},
@ -130,29 +132,12 @@ export default [
output: [
{
format: "es",
dir: "dist",
dir: "dist/admin",
sourcemap: true,
manualChunks: manualChunks,
chunkFileNames: "admin-[name].js",
},
],
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),
plugins: PLUGINS,
watch: {
clearScreen: false,
},
@ -164,29 +149,12 @@ export default [
output: [
{
format: "es",
dir: "dist",
dir: "dist/user",
sourcemap: true,
manualChunks: manualChunks,
chunkFileNames: "user-[name].js",
},
],
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),
plugins: PLUGINS,
watch: {
clearScreen: false,
},