Skip to content

Commit

Permalink
build: do more in webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Honlet committed Feb 27, 2025
1 parent 84e7d91 commit fc2b29c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ clean-files:

rm -f "$(ROOT)/.ovhconfig"
rm -f "$(ROOT)/www/built/backup"
rm -f "$(ROOT)/www/built/browsers.json"


dc-build:
docker compose build
Expand Down Expand Up @@ -194,7 +194,6 @@ $(HOME)/.ssh/id_rsa:
.PHONY: build
build: \
www/built/backup \
www/built/release_version.txt \
.ovhconfig

.ovhconfig: conf/ovhconfig .env
Expand All @@ -205,10 +204,6 @@ www/built/backup: bin/cr-live-backup.sh
@mkdir -p "$(dir $@)"
cp -f "$<" "$@"

www/built/release_version.txt:
@mkdir -p "$(dir $@)"
date > "$@"

.PHONY: update-references-browsers
update: update-references-browsers
update-references-browsers:
Expand Down
1 change: 1 addition & 0 deletions Makefile-frontend
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ $(FRONTEND_PUBLISHED)/frontend/ng1x.html: \
$(shell find src/ ) \
$(shell find legacy/app-old/ ) \
src/build.htaccess \
.browserslistrc \
webpack.config.js \
tsconfig.json

Expand Down
9 changes: 1 addition & 8 deletions Makefile-integration
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,11 @@ integration-build: $(INTEGRATION_BUILT_MARK)

$(INTEGRATION_BUILT_MARK): \
$(BACKEND_BUILT_MARK) \
$(FRONTEND_BUILT_MARK) \
www/built/browsers.json
$(FRONTEND_BUILT_MARK)

@mkdir -p "$(dir $@)"
@touch "$@"

www/built/browsers.json: .browserslistrc $(FRONTEND_DEPENDENCIES_MARK)
@mkdir -p "$(dir $@)"
# pipe will not work with snap
node_modules/.bin/browserslist --json | tee "$@"
@touch "$@"

.PHONY: integration-test
test: integration-test
integration-test: integration-test-desktop integration-test-playwright
Expand Down
30 changes: 27 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
/* eslint-env node */

import browserslist from "browserslist";
import HtmlWebpackPlugin from "html-webpack-plugin";
import child_process from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import url from "node:url";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const webRoot = path.join(__dirname, "/www/");
const webBuildRoot = "/built/frontend";
const builtRoot = path.join(webRoot, webBuildRoot);
const frontendRoot = path.join(webRoot, "/built");
// TODO: flattern this a bit
const webBuildRoot = "/frontend";
const builtRoot = path.join(frontendRoot, webBuildRoot);

fs.rmSync(builtRoot, { force: true, recursive: true });
fs.mkdirSync(builtRoot, { recursive: true });
fs.copyFileSync(
path.join(__dirname, "src/build.htaccess"),
path.join(webRoot, "built", ".htaccess")
path.join(frontendRoot, ".htaccess")
);

const browsers = browserslist();
fs.writeFileSync(
path.join(frontendRoot, "browsers.json"),
JSON.stringify(browsers)
);

fs.writeFileSync(
path.join(frontendRoot, "release_version.txt"),
JSON.stringify(
{
date: new Date().toISOString(),
git: child_process
.execSync("git rev-parse HEAD", { encoding: "UTF8" })
.trim()
},
null,
2
)
);

const isDebug = process.env.CRYPTOMEDIC_DEV ?? false;
Expand Down

0 comments on commit fc2b29c

Please sign in to comment.