mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
MISC: Add some more types to webpack.config.js
. (#1511)
Also fix some errors detected when turning on checking for it.
This commit is contained in:
parent
1e6e635ae3
commit
dd5fcc077a
@ -113,7 +113,7 @@
|
|||||||
"format": "prettier -c --write .",
|
"format": "prettier -c --write .",
|
||||||
"format:report": "prettier -c .",
|
"format:report": "prettier -c .",
|
||||||
"start": "electron .app/index.html",
|
"start": "electron .app/index.html",
|
||||||
"start:dev": "webpack serve --progress --env devServer --mode development",
|
"start:dev": "webpack serve --progress --mode development",
|
||||||
"build": "bash ./tools/build.sh production",
|
"build": "bash ./tools/build.sh production",
|
||||||
"build:dev": "bash ./tools/build.sh development",
|
"build:dev": "bash ./tools/build.sh development",
|
||||||
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src",
|
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src",
|
||||||
|
@ -7,15 +7,16 @@ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|||||||
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
||||||
const CopyPlugin = require("copy-webpack-plugin");
|
const CopyPlugin = require("copy-webpack-plugin");
|
||||||
|
|
||||||
/** @type import("webpack-cli").CallableOption} */
|
/** @type {import("webpack-cli").CallableOption} */
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
const isDevServer = (env || {}).devServer === true;
|
const isDevServer = (env || {}).WEBPACK_SERVE === true;
|
||||||
const runInContainer = (env || {}).runInContainer === true;
|
const runInContainer = (env || {}).runInContainer === true;
|
||||||
const isDevelopment = argv.mode === "development";
|
const isDevelopment = argv.mode === "development";
|
||||||
const enableReactRefresh = (env || {}).enableReactRefresh === true;
|
const enableReactRefresh = (env || {}).enableReactRefresh === true;
|
||||||
const outputDirectory = "dist";
|
const outputDirectory = "dist";
|
||||||
const entry = "./src/index.tsx";
|
const entry = "./src/index.tsx";
|
||||||
|
|
||||||
|
/** @type {webpack.StatsOptions} */
|
||||||
const statsConfig = {
|
const statsConfig = {
|
||||||
builtAt: true,
|
builtAt: true,
|
||||||
children: false,
|
children: false,
|
||||||
@ -27,6 +28,7 @@ module.exports = (env, argv) => {
|
|||||||
entrypoints: false,
|
entrypoints: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @type {webpack.Configuration["devServer"]} */
|
||||||
const devServerSettings = {
|
const devServerSettings = {
|
||||||
hot: true,
|
hot: true,
|
||||||
port: 8000,
|
port: 8000,
|
||||||
@ -42,17 +44,14 @@ module.exports = (env, argv) => {
|
|||||||
// By default, the webpack-dev-server is not exposed outside of localhost.
|
// By default, the webpack-dev-server is not exposed outside of localhost.
|
||||||
// When running in a container we need it accessible externally.
|
// When running in a container we need it accessible externally.
|
||||||
if (runInContainer) {
|
if (runInContainer) {
|
||||||
devServerSettings.disableHostCheck = true;
|
|
||||||
devServerSettings.host = "0.0.0.0";
|
devServerSettings.host = "0.0.0.0";
|
||||||
devServerSettings.watchOptions = {
|
|
||||||
poll: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current commit hash to inject into the app
|
// Get the current commit hash to inject into the app
|
||||||
// https://stackoverflow.com/a/38401256
|
// https://stackoverflow.com/a/38401256
|
||||||
const commitHash = require("child_process").execSync("git rev-parse --short HEAD").toString().trim();
|
const commitHash = require("child_process").execSync("git rev-parse --short HEAD").toString().trim();
|
||||||
|
|
||||||
|
/** @type {HtmlWebpackPlugin.Options} */
|
||||||
const htmlConfig = {
|
const htmlConfig = {
|
||||||
title: "Bitburner",
|
title: "Bitburner",
|
||||||
template: "src/index.html",
|
template: "src/index.html",
|
||||||
@ -192,6 +191,10 @@ module.exports = (env, argv) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
devServer: devServerSettings,
|
devServer: devServerSettings,
|
||||||
|
watchOptions: {
|
||||||
|
// When running in a container, we can't necesarily watch filesystem events.
|
||||||
|
poll: runInContainer ? true : undefined,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".tsx", ".ts", ".js", ".jsx"],
|
extensions: [".tsx", ".ts", ".js", ".jsx"],
|
||||||
alias: {
|
alias: {
|
||||||
|
Loading…
Reference in New Issue
Block a user