Loading client/src/onload/console.js 0 → 100644 +56 −0 Original line number Diff line number Diff line /** * This module disables the console in production, * and adds the ability to toggle console logging * using the global functions * enableDebugging() and disableDebugging() */ import { useLocalStorage } from "@vueuse/core"; import { watch } from "vue"; export function overrideProductionConsole() { let defaultEnabled = true; if (process.env.NODE_ENV == "production") { defaultEnabled = false; } const isEnabled = useLocalStorage("console-debugging-enabled", defaultEnabled); let storedConsole = null; const disableConsole = () => { storedConsole = console; // eslint-disable-next-line no-global-assign console = {}; Object.keys(storedConsole).forEach((key) => { console[key] = () => {}; }); }; const enableConsole = () => { if (storedConsole) { // eslint-disable-next-line no-global-assign console = storedConsole; } }; watch( () => isEnabled.value, (enabled) => { if (enabled) { enableConsole(); } else { disableConsole(); } }, { immediate: true } ); window.enableDebugging = () => { isEnabled.value = true; }; window.disableDebugging = () => { isEnabled.value = false; }; } client/src/onload/index.js +4 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ import "./publicPath"; // Default Font import "@fontsource/atkinson-hyperlegible"; import { overrideProductionConsole } from "./console"; // Module exports appear as objects on window.config in the browser export { standardInit } from "./standardInit"; export { initializations$, addInitialization, prependInitialization, clearInitQueue } from "./initQueue"; Loading @@ -21,6 +23,8 @@ export { getRootFromIndexLink } from "./getRootFromIndexLink"; // Client-side configuration variables (based on environment) import config from "config"; overrideProductionConsole(); if (!config.testBuild === true) { console.log(`Galaxy Client '${config.name}' build, dated ${config.buildTimestamp}`); console.debug("Full configuration:", config); Loading client/webpack.config.js +1 −10 Original line number Diff line number Diff line Loading @@ -37,16 +37,7 @@ module.exports = (env = {}, argv = {}) => { if (targetEnv == "production") { minimizations = { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { compress: { drop_console: true, }, }, }), new CssMinimizerPlugin(), ], minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], }; } else { minimizations = { Loading Loading
client/src/onload/console.js 0 → 100644 +56 −0 Original line number Diff line number Diff line /** * This module disables the console in production, * and adds the ability to toggle console logging * using the global functions * enableDebugging() and disableDebugging() */ import { useLocalStorage } from "@vueuse/core"; import { watch } from "vue"; export function overrideProductionConsole() { let defaultEnabled = true; if (process.env.NODE_ENV == "production") { defaultEnabled = false; } const isEnabled = useLocalStorage("console-debugging-enabled", defaultEnabled); let storedConsole = null; const disableConsole = () => { storedConsole = console; // eslint-disable-next-line no-global-assign console = {}; Object.keys(storedConsole).forEach((key) => { console[key] = () => {}; }); }; const enableConsole = () => { if (storedConsole) { // eslint-disable-next-line no-global-assign console = storedConsole; } }; watch( () => isEnabled.value, (enabled) => { if (enabled) { enableConsole(); } else { disableConsole(); } }, { immediate: true } ); window.enableDebugging = () => { isEnabled.value = true; }; window.disableDebugging = () => { isEnabled.value = false; }; }
client/src/onload/index.js +4 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ import "./publicPath"; // Default Font import "@fontsource/atkinson-hyperlegible"; import { overrideProductionConsole } from "./console"; // Module exports appear as objects on window.config in the browser export { standardInit } from "./standardInit"; export { initializations$, addInitialization, prependInitialization, clearInitQueue } from "./initQueue"; Loading @@ -21,6 +23,8 @@ export { getRootFromIndexLink } from "./getRootFromIndexLink"; // Client-side configuration variables (based on environment) import config from "config"; overrideProductionConsole(); if (!config.testBuild === true) { console.log(`Galaxy Client '${config.name}' build, dated ${config.buildTimestamp}`); console.debug("Full configuration:", config); Loading
client/webpack.config.js +1 −10 Original line number Diff line number Diff line Loading @@ -37,16 +37,7 @@ module.exports = (env = {}, argv = {}) => { if (targetEnv == "production") { minimizations = { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { compress: { drop_console: true, }, }, }), new CssMinimizerPlugin(), ], minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], }; } else { minimizations = { Loading