Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
npm install
- name: 'Build'
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
cd frontend
npm run build
- name: 'Archive Django Static Build Results'
Expand All @@ -65,7 +66,7 @@ jobs:
path: |
desktopApp/static
desktopApp/*.html
- name: 'Archive Django Static Build Results'
- name: 'Archive Web Static Build Results'
uses: actions/upload-artifact@v4
with:
name: web-main-static
Expand Down
59 changes: 58 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@eslint/compat": "^1.3.1",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.30.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/latlon-geohash": "^2.0.4",
"@types/leaflet": "^1.9.18",
Expand Down Expand Up @@ -73,6 +74,7 @@
"country-flag-icons": "^1.5.19",
"date-fns": "^4.1.0",
"file-replace-loader": "^1.4.2",
"fs-extra": "^11.3.1",
"i18next": "^25.2.1",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",
Expand Down
64 changes: 37 additions & 27 deletions frontend/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import path from 'path';
import { Configuration } from 'webpack';
import { Compiler, Configuration } from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { version } from './package.json';
import { Buffer } from 'buffer';
import fs from 'fs-extra';

// Declare __dirname for TypeScript
declare const __dirname: string;

const sourceBuild = 'static/frontend';
const outputPaths: string[] = [
path.resolve(__dirname, '../nodeapp/static'),
path.resolve(__dirname, '../desktopApp/static'),
path.resolve(__dirname, '../web/static'),
];

const config: Configuration = {
entry: './src/index.js',
module: {
Expand Down Expand Up @@ -38,11 +46,11 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
return {
...config,
output: {
path: path.resolve(__dirname, 'static/frontend'),
path: path.resolve(__dirname, sourceBuild),
filename:
argv.mode === 'production' ? `main.v${version}.[contenthash].js` : `main.v${version}.js`,
clean: true,
publicPath: '/static/frontend/',
publicPath: '/' + sourceBuild,
},
plugins: [
// Django
Expand Down Expand Up @@ -91,14 +99,7 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'selfhosted-pro',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../nodeapp/static'),
},
],
}),

// Desktop App
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
Expand All @@ -111,14 +112,7 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'desktop-basic',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../desktopApp/static'),
},
],
}),

// Web App
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
Expand All @@ -142,14 +136,30 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'web-pro',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../web/static'),
},
],
}),

{
apply: (compiler: Compiler) => {
compiler.hooks.afterEmit.tapAsync('CopyFilesPlugin', (_compilation, callback) => {
Promise.all(
outputPaths.map((outputPath) => {
const sourceDir = path.resolve(__dirname, sourceBuild);
return fs
.copy(sourceDir, outputPath)
.then(() => {
console.log(`Files copied to ${outputPath}`);
})
.catch((err) => {
console.error(`Error copying files to ${outputPath}:`, err);
});
}),
)
.then(() => {
callback();
})
.catch(callback);
});
},
},
],
};
};
Expand Down