Adjust frontend build script to allow aggressive caching
This commit is contained in:
parent
b68fa6f223
commit
cc1696a429
@ -18,7 +18,7 @@ export default class AccountService extends Server.AccountService<SessionContext
|
|||||||
id: ctx.user.uid,
|
id: ctx.user.uid,
|
||||||
username: ctx.user.username,
|
username: ctx.user.username,
|
||||||
name: ctx.user.name,
|
name: ctx.user.name,
|
||||||
birthday: ctx.user.birthday.valueOf(),
|
birthday: ctx.user.birthday?.valueOf(),
|
||||||
gender: ctx.user.gender as number as Gender,
|
gender: ctx.user.gender as number as Gender,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ export default class Web {
|
|||||||
|
|
||||||
constructor(config: WebConfig) {
|
constructor(config: WebConfig) {
|
||||||
this.server = express();
|
this.server = express();
|
||||||
|
this.server.set("trust proxy", 1);
|
||||||
this.port = Number(config.port);
|
this.port = Number(config.port);
|
||||||
this.registerMiddleware();
|
this.registerMiddleware();
|
||||||
this.registerUserSession();
|
this.registerUserSession();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
"postcss-url": "^10.1.3",
|
"postcss-url": "^10.1.3",
|
||||||
"rollup": "^3.20.2",
|
"rollup": "^3.20.2",
|
||||||
"rollup-plugin-esbuild": "^5.0.0",
|
"rollup-plugin-esbuild": "^5.0.0",
|
||||||
|
"rollup-plugin-hash": "^1.3.0",
|
||||||
"rollup-plugin-livereload": "^2.0.5",
|
"rollup-plugin-livereload": "^2.0.5",
|
||||||
"rollup-plugin-postcss": "^4.0.2",
|
"rollup-plugin-postcss": "^4.0.2",
|
||||||
"rollup-plugin-sizes": "^1.0.5",
|
"rollup-plugin-sizes": "^1.0.5",
|
||||||
|
@ -2,6 +2,6 @@ module.exports = {
|
|||||||
plugins: {
|
plugins: {
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
cssnano: {},
|
// cssnano: {},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@ import postcss from "rollup-plugin-postcss";
|
|||||||
import livereload from "rollup-plugin-livereload";
|
import livereload from "rollup-plugin-livereload";
|
||||||
import sveltePreprocess from "svelte-preprocess";
|
import sveltePreprocess from "svelte-preprocess";
|
||||||
import commonjs from "@rollup/plugin-commonjs";
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
|
import hash from "rollup-plugin-hash";
|
||||||
|
|
||||||
const VIEWS = ["home", "login", "popup", "user"];
|
const VIEWS = ["home", "login", "popup", "user"];
|
||||||
|
|
||||||
@ -27,9 +28,14 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
|
|||||||
""
|
""
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bundle_name = "";
|
||||||
const scripts = (files.js || [])
|
const scripts = (files.js || [])
|
||||||
.map(({ fileName }) => {
|
.map(({ fileName }) => {
|
||||||
const attrs = makeHtmlAttributes(attributes.script);
|
const attrs = makeHtmlAttributes(attributes.script);
|
||||||
|
if (fileName.startsWith("bundle.")) {
|
||||||
|
bundle_name = fileName;
|
||||||
|
}
|
||||||
return `<script src="${publicPath}${fileName}"${attrs}></script>`;
|
return `<script src="${publicPath}${fileName}"${attrs}></script>`;
|
||||||
})
|
})
|
||||||
.join("\n");
|
.join("\n");
|
||||||
@ -54,8 +60,7 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
|
|||||||
<head>
|
<head>
|
||||||
${metas}
|
${metas}
|
||||||
<title>${title}</title>
|
<title>${title}</title>
|
||||||
<link rel="stylesheet" href="bundle.css"/>
|
<link rel="stylesheet" href="${bundle_name.slice(0, -2)}css"/>
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto"/>
|
|
||||||
${links}
|
${links}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -66,14 +71,13 @@ const htmlTemplate = ({ attributes, meta, files, publicPath, title }) => {
|
|||||||
|
|
||||||
export default VIEWS.map((view) => ({
|
export default VIEWS.map((view) => ({
|
||||||
input: `src/pages/${view}/main.ts`,
|
input: `src/pages/${view}/main.ts`,
|
||||||
output: [
|
output: {
|
||||||
{
|
dir: `build/${view}`,
|
||||||
file: `build/${view}/bundle.min.js`,
|
entryFileNames: `bundle.[hash].min.js`,
|
||||||
format: "es",
|
format: "es",
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
name: view,
|
name: view,
|
||||||
},
|
},
|
||||||
],
|
|
||||||
plugins: [
|
plugins: [
|
||||||
svelte({
|
svelte({
|
||||||
emitCss: true,
|
emitCss: true,
|
||||||
@ -106,9 +110,12 @@ export default VIEWS.map((view) => ({
|
|||||||
title: `Rullup bundle for ${view}`,
|
title: `Rullup bundle for ${view}`,
|
||||||
}),
|
}),
|
||||||
postcss({
|
postcss({
|
||||||
extract: `bundle.css`, //TODO: Check if it should be enabled
|
extract: true, // `bundle.css`, //TODO: Check if it should be enabled
|
||||||
// inject: true,
|
// inject: true,
|
||||||
}),
|
}),
|
||||||
|
hash({
|
||||||
|
dest: "bundle.[hash].min.js",
|
||||||
|
}),
|
||||||
// dev && livereload(),
|
// dev && livereload(),
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/openauth",
|
"name": "@hibas123/openauth",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
43
yarn.lock
43
yarn.lock
@ -581,6 +581,7 @@ __metadata:
|
|||||||
postcss-url: ^10.1.3
|
postcss-url: ^10.1.3
|
||||||
rollup: ^3.20.2
|
rollup: ^3.20.2
|
||||||
rollup-plugin-esbuild: ^5.0.0
|
rollup-plugin-esbuild: ^5.0.0
|
||||||
|
rollup-plugin-hash: ^1.3.0
|
||||||
rollup-plugin-livereload: ^2.0.5
|
rollup-plugin-livereload: ^2.0.5
|
||||||
rollup-plugin-postcss: ^4.0.2
|
rollup-plugin-postcss: ^4.0.2
|
||||||
rollup-plugin-sizes: ^1.0.5
|
rollup-plugin-sizes: ^1.0.5
|
||||||
@ -4385,6 +4386,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"hasha@npm:^2.2.0":
|
||||||
|
version: 2.2.0
|
||||||
|
resolution: "hasha@npm:2.2.0"
|
||||||
|
dependencies:
|
||||||
|
is-stream: ^1.0.1
|
||||||
|
pinkie-promise: ^2.0.0
|
||||||
|
checksum: 1855680c0e8a1b92686f816f2f224e184e5f2422f2ddef4f05184ea57bf954cecc017598af08b84c6aa723ccc38353469d4f143869ecfafedf1c50aec0e7ed4e
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"he@npm:^1.2.0":
|
"he@npm:^1.2.0":
|
||||||
version: 1.2.0
|
version: 1.2.0
|
||||||
resolution: "he@npm:1.2.0"
|
resolution: "he@npm:1.2.0"
|
||||||
@ -4858,6 +4869,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"is-stream@npm:^1.0.1":
|
||||||
|
version: 1.1.0
|
||||||
|
resolution: "is-stream@npm:1.1.0"
|
||||||
|
checksum: 063c6bec9d5647aa6d42108d4c59723d2bd4ae42135a2d4db6eadbd49b7ea05b750fd69d279e5c7c45cf9da753ad2c00d8978be354d65aa9f6bb434969c6a2ae
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"is-stream@npm:^2.0.0":
|
"is-stream@npm:^2.0.0":
|
||||||
version: 2.0.1
|
version: 2.0.1
|
||||||
resolution: "is-stream@npm:2.0.1"
|
resolution: "is-stream@npm:2.0.1"
|
||||||
@ -6207,6 +6225,22 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"pinkie-promise@npm:^2.0.0":
|
||||||
|
version: 2.0.1
|
||||||
|
resolution: "pinkie-promise@npm:2.0.1"
|
||||||
|
dependencies:
|
||||||
|
pinkie: ^2.0.0
|
||||||
|
checksum: b53a4a2e73bf56b6f421eef711e7bdcb693d6abb474d57c5c413b809f654ba5ee750c6a96dd7225052d4b96c4d053cdcb34b708a86fceed4663303abee52fcca
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"pinkie@npm:^2.0.0":
|
||||||
|
version: 2.0.4
|
||||||
|
resolution: "pinkie@npm:2.0.4"
|
||||||
|
checksum: b12b10afea1177595aab036fc220785488f67b4b0fc49e7a27979472592e971614fa1c728e63ad3e7eb748b4ec3c3dbd780819331dad6f7d635c77c10537b9db
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"pirates@npm:^4.0.1":
|
"pirates@npm:^4.0.1":
|
||||||
version: 4.0.5
|
version: 4.0.5
|
||||||
resolution: "pirates@npm:4.0.5"
|
resolution: "pirates@npm:4.0.5"
|
||||||
@ -7364,6 +7398,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"rollup-plugin-hash@npm:^1.3.0":
|
||||||
|
version: 1.3.0
|
||||||
|
resolution: "rollup-plugin-hash@npm:1.3.0"
|
||||||
|
dependencies:
|
||||||
|
hasha: ^2.2.0
|
||||||
|
checksum: ecb39f6d296664377436ab42defdc6250a4b7bd906b53aea4cb7026969a5c55a874d57c11561c98dc89c29e8b89f9dc0058ad13d7e3f5aef6247962fdf80d2bb
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"rollup-plugin-includepaths@npm:^0.2.4":
|
"rollup-plugin-includepaths@npm:^0.2.4":
|
||||||
version: 0.2.4
|
version: 0.2.4
|
||||||
resolution: "rollup-plugin-includepaths@npm:0.2.4"
|
resolution: "rollup-plugin-includepaths@npm:0.2.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user