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
1 change: 1 addition & 0 deletions workspaces/generate-health-report/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const COMMANDS = [
"yarn workspace @code-chronicles/leetcode-api codegen",
"yarn workspace @code-chronicles/leetcode-zen-mode build",
"yarn workspace @code-chronicles/post-leetcode-potd-to-discord build",
"yarn workspace @code-chronicles/simon-game build",
];

async function main(): Promise<void> {
Expand Down
3 changes: 0 additions & 3 deletions workspaces/simon-game/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
dist/

data.json
secrets_DO_NOT_COMMIT_OR_SHARE.json
13 changes: 0 additions & 13 deletions workspaces/simon-game/index.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from "react";
import ReactDOMServer from "react-dom/server";
import type { Compiler } from "webpack";

import { App } from "../../app/components/App.tsx";

export class WriteIndexHtmlWebpackPlugin {
apply(compiler: Compiler) {
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
compilation.hooks.processAssets.tap(
{
name: this.constructor.name,
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
},
() => {
compilation.emitAsset(
"index.html",
new compiler.webpack.sources.RawSource(
"<!DOCTYPE html>\n" +
ReactDOMServer.renderToStaticMarkup(
<html lang="en-US">
<head>
<meta charSet="utf-8" />
<title>Simon Game</title>
<script async src="main.js" />
<script async src="dependencies.js" />
</head>
<body>
<div id="main">
<App />
</div>
</body>
</html>,
) +
"\n",
),
);
},
);
});
}
}
9 changes: 7 additions & 2 deletions workspaces/simon-game/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import path from "node:path";
import type { Configuration } from "webpack";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";

import { WriteIndexHtmlWebpackPlugin } from "./src/scripts/build/WriteIndexHtmlWebpackPlugin.tsx";

const config: Configuration = {
target: "web",
// TODO: for Chrome extension we will need devtool: "cheap-source-map" since we can't eval.
entry: "./src/app/main.tsx",
output: {
filename: "[name].js",
Expand Down Expand Up @@ -33,7 +34,11 @@ const config: Configuration = {
conditionNames: ["import"],
},

plugins: [new ForkTsCheckerWebpackPlugin()],
plugins: [
new ForkTsCheckerWebpackPlugin(),

new WriteIndexHtmlWebpackPlugin(),
],

optimization: {
splitChunks: {
Expand Down
Loading