Skip to content

Commit

Permalink
[#233] Setup project for initial deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ido-Barnea committed Feb 27, 2024
1 parent 56dc699 commit 319dc65
Show file tree
Hide file tree
Showing 71 changed files with 127 additions and 1,360 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"prettier"
],
"plugins": ["@typescript-eslint", "prettier"],
"files": ["*.ts"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: webpack serve --config webpack.config.prod.ts
web: npm run build && npm run start
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1,317 changes: 78 additions & 1,239 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
"name": "chess-but-better",
"description": "Chess with an added layer of complexity",
"scripts": {
"start": "webpack serve --config webpack.config.dev.ts",
"lint": "npx nx run-many --target lint",
"format": "npx nx format:write",
"test": "npx nx run-many --target test --all",
"build": "webpack --config webpack.config.prod.ts"
"dev": "webpack serve --config webpack.config.ts",
"build": "webpack --config webpack.config.ts",
"start": "node server.js"
},
"author": "Ido Barnea",
"license": "Apache-2.0",
"dependencies": {
"copy-webpack-plugin": "^12.0.2",
"express": "^4.18.2",
"html-webpack-plugin": "^5.6.0",
"webpack-cli": "^5.1.4"
},
"devDependencies": {
"@nx/eslint-plugin": "16.10.0",
"@nx/jest": "^17.2.7",
Expand All @@ -18,14 +25,11 @@
"@nx/workspace": "16.10.0",
"@types/jest": "^29.5.11",
"@types/node": "18.7.1",
"@types/webpack-dev-server": "^4.7.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"copy-webpack-plugin": "^12.0.2",
"eslint": "~8.46.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^5.1.3",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.4.1",
"nx": "17.2.7",
Expand All @@ -35,11 +39,6 @@
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"ts-node": "10.9.1",
"typescript": "~5.1.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"webpack": "^5.90.3"
"typescript": "~5.1.3"
}
}
23 changes: 23 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require('express');
const path = require('path');

const app = express();
const PORT = process.env.PORT || 5000;

app.use(express.static(path.join(__dirname, 'dist')));

app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'views', 'home.html'));
});

app.get('/room', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'views', 'room.html'));
});

app.use((req, res, next) => {
res.status(404).sendFile(path.join(__dirname, 'dist', 'views', '404.html'));
});

app.listen(PORT, () => {
console.log(`[Server] Listening on port ${PORT}.`);
});
13 changes: 8 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"compilerOptions": {
"module": "CommonJS",
"target": "es2016",
"experimentalDecorators": true,
"jsxImportSource": "preact",
"module": "commonjs",
"rootDir": ".",
"rootDir": "./core",
"sourceMap": true,
"outDir": "output",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
"skipLibCheck": true,
},
"include": [
"core/**/*.ts"
]
}
77 changes: 0 additions & 77 deletions webpack.config.dev.ts

This file was deleted.

33 changes: 6 additions & 27 deletions webpack.config.prod.ts → webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import path from 'path';
import webpack from 'webpack';
import { Configuration as DevServerConfiguration } from 'webpack-dev-server';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';

interface CustomConfiguration extends webpack.Configuration {
devServer?: DevServerConfiguration;
}

const config: CustomConfiguration = {
const config: webpack.Configuration = {
mode: 'production',
entry: {
room: './development/pages/Room.ts',
room: './core/development/pages/Room.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
Expand All @@ -36,42 +31,26 @@ const config: CustomConfiguration = {
plugins: [
new HtmlWebpackPlugin({
filename: 'views/home.html',
template: './views/home.html',
template: './core/views/home.html',
chunks: [],
favicon: './assets/logo.svg',
}),
new HtmlWebpackPlugin({
filename: 'views/room.html',
template: './views/room.html',
template: './core/views/room.html',
chunks: ['room'],
favicon: './assets/logo.svg',
}),
new HtmlWebpackPlugin({
filename: 'views/404.html',
template: './views/404.html',
template: './core/views/404.html',
chunks: [],
favicon: './assets/logo.svg',
}),
new CopyWebpackPlugin({
patterns: [{ from: 'styles', to: 'styles' }],
patterns: [{ from: './core/styles', to: 'styles' }],
}),
],
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
port: 8080,
client: {
logging: 'none',
},
historyApiFallback: {
rewrites: [
{ from: /^\/(home)?$/, to: '/views/home.html' },
{ from: /^\/room$/, to: '/views/room.html' },
{ from: /./, to: '/views/404.html' },
],
},
},
};

export default config;

0 comments on commit 319dc65

Please sign in to comment.