Skip to content

Commit

Permalink
#134, #156, #163: Begin support of webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Sothatsit committed May 26, 2021
1 parent fcc3ed0 commit 13d417c
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 83 deletions.
5 changes: 5 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
78 changes: 2 additions & 76 deletions compilation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

"src/status/lost.html": "lost.html"
},

"css": {
"index.css": [
"src/common/base.css",
Expand Down Expand Up @@ -90,83 +91,8 @@
"src/status/lost.css"
]
},
"javascript": {
"index.js": [
"src/common/utils.js",
"src/common/resources/resource_loader.js",
"src/common/resources/image_system.js",
"src/home/home_resources.js"
],
"game/index.js": [
"src/game/lib/reconnecting-websocket.js",
"src/game/analytics/analytics.js",
"src/game/analytics/stats.js",
"src/game/game/board.js",
"src/game/model/model.js",
"src/game/model/dice_model.js",

"src/game/network/packet_reader.js",
"src/game/network/packet_writer.js",
"src/game/network/packets.js",
"src/game/network/network_packets.js",
"src/game/network/ai_packets.js",
"src/game/network/network.js",
"src/game/game/game.js",

"src/game/ui/menu.js",
"src/game/ui/layout.js",

"src/game/rendering/particles.js",
"src/game/rendering/curves.js",
"src/game/rendering/renderer.js",
"src/game/rendering/render_menu.js",
"src/game/rendering/render_overlays.js",
"src/game/rendering/render_game_ui.js",
"src/game/rendering/render_dice.js",
"src/game/rendering/render_board.js",

"src/game/ui/screens.js",
"src/game/client.js"
],
"game/computer_worker.js": [
"src/common/utils.js",
"src/game/network/packet_reader.js",
"src/game/network/packet_writer.js",
"src/game/network/packets.js",
"src/game/network/ai_packets.js",
"src/game/game/board.js",
"res/royal_ur_analysis/api/api.js",
"src/game/game/simulation.js",
"src/game/game/computer_worker.js"
],
"game/resources.js": [
"src/common/utils.js",
"src/common/resources/resource_types.js",
"src/common/resources/resource_loader.js",
"src/common/resources/audio_system.js",
"src/common/resources/image_system.js",
"src/game/game_resources.js"
],
"article_resources.js": [
"src/common/utils.js",
"src/common/resources/resource_loader.js",
"src/common/resources/image_system.js",
"src/articles/base/article_resources.js",
"src/articles/base/articles.js"
],
"dice/index.js": [
"src/common/utils.js",
"src/common/resources/resource_loader.js",
"src/common/resources/audio_system.js",
"src/common/resources/image_system.js",
"src/common/resources/resource_types.js",
"src/articles/base/article_resources.js",

"src/game/model/dice_model.js",
"src/game/rendering/render_dice.js",
"src/articles/learn/dice.js"
]
},
"javascript": {},

"resources": {
"src/.htaccess": ".htaccess",
Expand Down
27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
{
"name": "royalur-net",
"author": {
"name": "Paddy Lamont",
"email": "padraiglamont@gmail.com",
"url": "https://github.com/Sothatsit"
},
"description": "A free and open-source website to let people play and learn about The Royal Game of Ur.",
"version": "1.0.0",
"license": "GPL-3.0-or-later",
"homepage": "https://royalur.net",
"repository": {
"type": "git",
"url": "git+https://github.com/Sothatsit/RoyalUrClient.git"
},
"bugs": {
"url": "https://github.com/Sothatsit/RoyalUrClient/issues"
},
"private": "true",
"scripts": {
"build": "webpack --mode production"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"autoprefixer": "^10.2.5",
"postcss-cli": "^8.3.1",
"postcss-preset-env": "^6.7.0",
"uglify-js": "^3.11.5",
"uglifycss": "^0.0.29"
"terser-webpack-plugin": "*",
"uglifycss": "^0.0.29",
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0"
}
}
2 changes: 1 addition & 1 deletion src/articles/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ <h2 id="sponsors"><a href="#sponsors">Sponsor the Site</a></h2>
<include src="src/common/footer/footer.html" />

<!-- JAVASCRIPT TO LOAD IMAGES -->
<script src="/article_resources.[ver].js"></script>
<script src="/articles.[ver].js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/articles/learn/learn.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ <h1>Learn about the The Royal Game of Ur</h1>
<include src="src/common/footer/footer.html" />

<!-- JAVASCRIPT TO LOAD IMAGES -->
<script src="/article_resources.[ver].js"></script>
<script src="/articles.[ver].js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/articles/learn/rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ <h2>Play The Royal Game of Ur</h2>
<include src="src/common/footer/footer.html" />

<!-- JAVASCRIPT TO LOAD IMAGES -->
<script src="/article_resources.[ver].js"></script>
<script src="/articles.[ver].js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/articles/learn/watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ <h2 id="deciphering-the-rules"><a href="#deciphering-the-rules">
<include src="src/common/footer/footer.html" />

<!-- JAVASCRIPT TO LOAD IMAGES -->
<script src="/article_resources.[ver].js"></script>
<script src="/articles.[ver].js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/articles/privacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ <h2 id="contact-us"><a href="#contact-us">Contact Us</a></h2>
<include src="src/common/footer/footer.html" />

<!-- JAVASCRIPT TO LOAD IMAGES -->
<script src="/article_resources.[ver].js"></script>
<script src="/articles.[ver].js"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions src/home/home_resources.js → src/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// This file manages the loading of resources for the home page.
//

import "../common/utils"
import "../common/resources/resource_loader"
import "../common/resources/image_system"

const resourceLoader = new ResourceLoader(),
imageSystem = new ImageSystem(resourceLoader);

Expand Down
55 changes: 55 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require("path"),
TerserPlugin = require("terser-webpack-plugin");

/** Returns an absolute path of a file relative to this config. **/
function abs(...args) {
return path.resolve.apply(this, [__dirname].concat(args));
}

/** Joins several relative file pieces into one relative file path. **/
function rel(...args) {
return "./" + path.join.apply(this, args);
}

module.exports = {
output: {
path: abs('build', 'js')
},
entry: {
home: {
import: rel('src', 'home', 'home.js'),
filename: rel('index.js')
},
game: {
import: rel('src', 'game', 'client.js'),
filename: rel('game', 'index.js')
},
gameWorker: {
import: rel('src', 'game', 'game', 'computer_worker.js'),
filename: rel('game', 'computer_worker.js')
},
gameResources: {
import: rel('src', 'game', 'game_resources.js'),
filename: rel('game', 'resources.js')
},
articles: {
import: rel('src', 'articles', 'base', 'articles.js'),
filename: rel('articles.js')
},
dice: {
import: rel('src', 'articles', 'learn', 'dice.js'),
filename: rel('dice', 'index.js')
}
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: false
}
})

]
},
};

0 comments on commit 13d417c

Please sign in to comment.