Fixed some minor project setup issues

master
WolverinDEV 2021-03-17 14:00:35 +01:00
parent 503ca5db8b
commit ff610bf3ee
5 changed files with 34 additions and 60 deletions

View File

@ -16,10 +16,12 @@ export = api => {
} }
] ]
]; ];
const plugins = [ const plugins = [
["@babel/transform-runtime"], ["@babel/transform-runtime"],
["@babel/plugin-transform-modules-commonjs"] ["@babel/plugin-transform-modules-commonjs"]
]; ];
return { return {
presets, presets,
plugins plugins

View File

@ -1,3 +1,3 @@
import "./index.scss"; import "./index.scss";
import "./loader.scss"; import "./loader.scss";
import "./overlay.css"; import "./overlay.scss";

View File

@ -45,9 +45,11 @@
margin-top: .5em margin-top: .5em
} }
} }
}
@media (max-height: 750px) { @media (max-height: 750px) {
:global {
#critical-load .container { #critical-load .container {
top: unset; top: unset;
} }

View File

@ -5,7 +5,6 @@ The following tools or applications are required to develop the web client:
- [1.2 NodeJS](#12-nodejs) - [1.2 NodeJS](#12-nodejs)
- [1.2.2 NPM](#122-npm) - [1.2.2 NPM](#122-npm)
- [1.3 Git bash](#13-git-bash) - [1.3 Git bash](#13-git-bash)
- [1.4 Rust (Options)](#14-rust-optional-will-be-installed-automatically)
### 1.1 IDE ### 1.1 IDE
It does not matter which IDE you use, It does not matter which IDE you use,
@ -27,10 +26,6 @@ IMPORTANT: NPM must be available within the PATH environment variable!
For using the `.sh` build scripts you require Git Bash. For using the `.sh` build scripts you require Git Bash.
A minimum of 4.2 is recommend, but in general every modern version should work. A minimum of 4.2 is recommend, but in general every modern version should work.
### 1.4 Rust (Optional, will be installed automatically)
For building the web client audio library, you may want to install rust in advance.
Since it will be installed when executing the install libraries script, I'm not going into more detail here.
## 2.0 Project initialization ## 2.0 Project initialization
### 2.1 Cloning the WebClient ### 2.1 Cloning the WebClient

View File

@ -3,11 +3,9 @@ import * as fs from "fs";
import trtransformer from "./tools/trgen/ts_transformer"; import trtransformer from "./tools/trgen/ts_transformer";
import {exec} from "child_process"; import {exec} from "child_process";
import * as util from "util"; import * as util from "util";
import * as path from "path";
import {Configuration} from "webpack"; import { DefinePlugin, Configuration } from "webpack";
const path = require('path');
const webpack = require("webpack");
import { Plugin as SvgSpriteGenerator } from "webpack-svg-sprite-generator"; import { Plugin as SvgSpriteGenerator } from "webpack-svg-sprite-generator";
const ManifestGenerator = require("./webpack/ManifestPlugin"); const ManifestGenerator = require("./webpack/ManifestPlugin");
@ -53,17 +51,7 @@ const generateDefinitions = async (target: string) => {
timestamp: timestamp, timestamp: timestamp,
entry_chunk_name: JSON.stringify(target === "web" ? "shared-app" : "client-app") entry_chunk_name: JSON.stringify(target === "web" ? "shared-app" : "client-app")
} as BuildDefinitions } as BuildDefinitions
}; } as any;
};
const isLoaderFile = (file: string) => {
if(file.startsWith(__dirname)) {
const path = file.substr(__dirname.length).replace(/\\/g, "/");
if(path.startsWith("/loader/")) {
return true;
}
}
return false;
}; };
const generateIndexPlugin = (target: "web" | "client"): HtmlWebpackPlugin => { const generateIndexPlugin = (target: "web" | "client"): HtmlWebpackPlugin => {
@ -102,21 +90,23 @@ export const config = async (target: "web" | "client"): Promise<Configuration &
//"devel-main": "./shared/js/devel_main.ts" //"devel-main": "./shared/js/devel_main.ts"
}, },
devtool: isDevelopment ? "inline-source-map" : undefined, devtool: isDevelopment ? "inline-source-map" : "source-map",
mode: isDevelopment ? "development" : "production", mode: isDevelopment ? "development" : "production",
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new DefinePlugin(await generateDefinitions(target)),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: isDevelopment ? '[name].css' : '[name].[contenthash].css', filename: isDevelopment ? "[name].[contenthash].css" : "[contenthash].css",
chunkFilename: isDevelopment ? '[id].css' : '[id].[contenthash].css', chunkFilename: isDevelopment ? "[name].[contenthash].css" : "[contenthash].css",
ignoreOrder: true ignoreOrder: true
}), }),
new ManifestGenerator({ new ManifestGenerator({
outputFileName: "manifest.json", outputFileName: "manifest.json",
context: __dirname context: __dirname
}), }),
//new BundleAnalyzerPlugin(),
new webpack.DefinePlugin(await generateDefinitions(target)),
new SvgSpriteGenerator({ new SvgSpriteGenerator({
dtsOutputFolder: path.join(__dirname, "shared", "svg-sprites"), dtsOutputFolder: path.join(__dirname, "shared", "svg-sprites"),
publicPath: "js/", publicPath: "js/",
@ -154,8 +144,11 @@ export const config = async (target: "web" | "client"): Promise<Configuration &
} }
} }
}), }),
generateIndexPlugin(target), generateIndexPlugin(target),
new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin), new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin),
//new BundleAnalyzerPlugin(),
].filter(e => !!e), ].filter(e => !!e),
module: { module: {
@ -189,12 +182,18 @@ export const config = async (target: "web" | "client"): Promise<Configuration &
] ]
}, },
{ {
test: (module: string) => module.match(/\.tsx?$/) && !isLoaderFile(module), test: /\.tsx?$/,
exclude: /node_modules/, exclude: /node_modules/,
use: [ use: [
{ {
loader: 'ts-loader', loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
}
},
{
loader: "ts-loader",
options: { options: {
context: __dirname, context: __dirname,
colors: true, colors: true,
@ -212,52 +211,28 @@ export const config = async (target: "web" | "client"): Promise<Configuration &
} }
] ]
}, },
{
test: (module: string) => module.match(/\.tsx?$/) && isLoaderFile(module),
exclude: /(node_modules|bower_components)/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"] //Preset used for env setup
}
},
{
loader: "ts-loader",
options: {
transpileOnly: true
}
}
]
},
{ {
test: /\.was?t$/, test: /\.was?t$/,
use: [ use: [
"./webpack/WatLoader.js" "./webpack/WatLoader.js"
] ]
}, },
{
test: /ChangeLog\.md$|\.html$/i,
type: "asset/source",
},
{ {
test: /\.svg$/, test: /\.svg$/,
use: 'svg-inline-loader' use: 'svg-inline-loader'
}, },
{
test: /ChangeLog\.md$|\.html$/i,
use: {
loader: "raw-loader",
options: {
esModule: false
}
},
},
{ {
test: /\.(png|jpg|jpeg|gif)?$/, test: /\.(png|jpg|jpeg|gif)?$/,
use: 'file-loader', type: "asset/resource"
}, },
] ]
} as any, } as any,
resolve: { resolve: {
extensions: ['.tsx', '.ts', '.js', ".scss", ".css", ".wasm"], extensions: ['.tsx', '.ts', '.js', ".scss"],
alias: { alias: {
"vendor/xbbcode": path.resolve(__dirname, "vendor/xbbcode/src"), "vendor/xbbcode": path.resolve(__dirname, "vendor/xbbcode/src"),
"tc-events": path.resolve(__dirname, "vendor/TeaEventBus/src/index.ts"), "tc-events": path.resolve(__dirname, "vendor/TeaEventBus/src/index.ts"),