Skip to content

Commit 37a89d4

Browse files
author
ozelot379
committed
Add debug webapp
1 parent 6c7b3e9 commit 37a89d4

8 files changed

Lines changed: 1133 additions & 160 deletions

File tree

‎.npmignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ input
44
node_modules
55
output
66
src
7-
tests
87
tmp
9-
webpack.config.js
8+
webpack.config.cli.js
9+
webpack.config.webapp.js

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [x]
4+
- Add debug webapp
5+
36
## [1.11.2]
47
- Title image convert
58

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,14 @@ yarn
152152

153153
Then you can start the debug
154154

155+
cli:
155156
```bash
156-
yarn debug
157+
yarn debug:cli
158+
```
159+
160+
webapp:
161+
```bash
162+
yarn debug:webapp
157163
```
158164

159165
You can create a build

‎package.json‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"uuid": "^3.3.3",
4444
"webpack": "^4.39.2",
4545
"webpack-cli": "^3.3.7",
46+
"webpack-dev-server": "^3.8.2",
4647
"webpack-pwa-manifest": "^4.0.0",
4748
"worker-loader": "^2.0.0",
4849
"yargs": "^14.0.0"
@@ -55,10 +56,10 @@
5556
"ConvertMinecraftJavaTextureToBedrock": "dist/cli.js"
5657
},
5758
"scripts": {
58-
"build": "webpack",
59-
"build:dev": "webpack --mode=development",
59+
"build": "yarn build --config ./webpack.config.cli.js && yarn build --config ./webpack.config.webapp.js",
6060
"cli": "node ./dist/cli.js",
61-
"debug": "yarn build:dev && yarn cli",
61+
"debug:cli": "webpack --mode=development --config ./webpack.config.cli.js && yarn cli",
62+
"debug:webapp": "webpack-dev-server --config ./webpack.config.webapp.js",
6263
"prepublishOnly": "yarn build && yarn publishGhPages",
6364
"publishGhPages": "gh-pages -d ./dist/webapp"
6465
}

‎webpack.config.cli.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const {BannerPlugin} = require("webpack");
2+
3+
module.exports = (env, argv) => {
4+
const isDebug = (argv.mode === "development");
5+
6+
return {
7+
entry: {
8+
index: "./src/index.js",
9+
cli: "./src/cli.js"
10+
},
11+
mode: (isDebug ? "development" : "production"),
12+
output: {
13+
filename: "[name].js",
14+
path: __dirname + "/dist",
15+
libraryTarget: "umd"
16+
},
17+
plugins: [
18+
new BannerPlugin({
19+
banner: "#!/usr/bin/env node",
20+
raw: true,
21+
exclude: "*",
22+
include: "cli.js"
23+
}),
24+
],
25+
target: "node"
26+
};
27+
};

‎webpack.config.js‎

Lines changed: 0 additions & 131 deletions
This file was deleted.

‎webpack.config.webapp.js‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
2+
const HtmlWebpackPlugin = require("html-webpack-plugin");
3+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
4+
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
5+
const PACKAGE = require("./package");
6+
const TerserJSPlugin = require("terser-webpack-plugin");
7+
8+
module.exports = (env, argv) => {
9+
const isDebug = (argv.mode === "development");
10+
11+
return {
12+
devServer: {
13+
host: "0.0.0.0",
14+
open: true
15+
},
16+
entry: {
17+
index: "./src/webapp/js/index.js"
18+
},
19+
mode: (isDebug ? "development" : "production"),
20+
module: {
21+
rules: [
22+
{
23+
test: /\.less$/,
24+
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
25+
},
26+
{
27+
test: /worker\.js$/,
28+
loader: "worker-loader",
29+
options: {
30+
name: "[name].[ext]"
31+
}
32+
}
33+
]
34+
},
35+
optimization: {
36+
minimizer: (isDebug ? [] : [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin()]),
37+
},
38+
output: {
39+
filename: "index.js",
40+
path: __dirname + "/dist/webapp",
41+
globalObject: "this" // Fix worker
42+
},
43+
plugins: [
44+
new HtmlWebpackPlugin({
45+
minify: (isDebug ? false : {
46+
collapseWhitespace: true,
47+
removeComments: true,
48+
removeRedundantAttributes: true,
49+
removeScriptTypeAttributes: true,
50+
removeStyleLinkTypeAttributes: true,
51+
useShortDoctype: true
52+
}),
53+
template: "./src/webapp/html/index.html"
54+
}),
55+
new MiniCssExtractPlugin(),
56+
new FaviconsWebpackPlugin({
57+
devMode: "webapp",
58+
logo: "./src/webapp/img/icon.svg",
59+
mode: "webapp",
60+
favicons: {
61+
appDescription: PACKAGE.description,
62+
appName: PACKAGE.productName,
63+
appShortName: PACKAGE.productName,
64+
appleStatusBarStyle: "black",
65+
background: "#FFFFFF",
66+
developerName: PACKAGE.author,
67+
developerURL: null,
68+
dir: null,
69+
display: "standalone",
70+
icons: {
71+
android: true,
72+
appleIcon: true,
73+
favicons: true,
74+
appleStartup: false,
75+
coast: false,
76+
firefox: false,
77+
windows: false,
78+
yandex: false
79+
},
80+
lang: null,
81+
manifestRelativePaths: true,
82+
orientation: "any",
83+
path: "./",
84+
start_url: "..",
85+
theme_color: "#795548",
86+
version: PACKAGE.version
87+
},
88+
prefix: "webapp",
89+
publicPath: "./"
90+
})
91+
],
92+
resolve: {
93+
alias: {
94+
fs: __dirname + "/src/fs_browser_null.js",
95+
"fs-extra": __dirname + "/src/fs_browser_null.js",
96+
"graceful-fs": __dirname + "/src/fs_browser_null.js",
97+
path: "path-browserify", // Latest version which supports `path.parse`
98+
readdirp: __dirname + "/src/fs_browser_null.js"
99+
}
100+
},
101+
target: "web"
102+
};
103+
};

0 commit comments

Comments
 (0)