diff --git a/README.md b/README.md index 0bf8e29a..2c689a3d 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,22 @@ in ESP3D-WEBUI directory (repository root) ``` npm run build ``` +Will generate production and debug versions for grbl and printer + + +``` +npm run build-debug +``` +Will generate debug versions for grbl and printer, which contain all console.log message. + + +``` +npm run build-prod +``` +Will generate production versions for grbl and printer, cleaned from all `console.log` messages. + +you can even go to more atomic level with : `npm run build-printer`, `npm run build-grbl`, `npm run build-printer-debug`, `npm run build-grbl-debug`, `npm run build-lang` + ### Code beautify with prettier use pluggin or cli diff --git a/dist/grbl/debug/index.html.gz b/dist/grbl/debug/index.html.gz new file mode 100644 index 00000000..5a3b28aa Binary files /dev/null and b/dist/grbl/debug/index.html.gz differ diff --git a/dist/grbl/index.html.gz b/dist/grbl/index.html.gz deleted file mode 100644 index c9dc06c9..00000000 Binary files a/dist/grbl/index.html.gz and /dev/null differ diff --git a/dist/grbl/production/index.html.gz b/dist/grbl/production/index.html.gz new file mode 100644 index 00000000..4cfc1e9e Binary files /dev/null and b/dist/grbl/production/index.html.gz differ diff --git a/dist/printer/debug/index.html.gz b/dist/printer/debug/index.html.gz new file mode 100644 index 00000000..3e8d466e Binary files /dev/null and b/dist/printer/debug/index.html.gz differ diff --git a/dist/printer/index.html.gz b/dist/printer/index.html.gz deleted file mode 100644 index 8fd99ad9..00000000 Binary files a/dist/printer/index.html.gz and /dev/null differ diff --git a/dist/printer/production/index.html.gz b/dist/printer/production/index.html.gz new file mode 100644 index 00000000..3b7d3c3a Binary files /dev/null and b/dist/printer/production/index.html.gz differ diff --git a/package.json b/package.json index cd7477eb..8905fe58 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,13 @@ "description": "Preact version of WebUI for ESP3D per @aganov suggestion", "main": "index.js", "scripts": { - "build-grbl": "cross-env NODE_ENV=production TARGET_ENV=grbl webpack --mode=production", - "build-printer": "cross-env NODE_ENV=production TARGET_ENV=printer webpack --mode=production", - "build": "npm run build-printer & npm run build-grbl & npm run build-lang", + "build-grbl-debug": "cross-env NODE_ENV=production TARGET_ENV=grbl BUILD_ENV=debug webpack --mode=production", + "build-printer-debug": "cross-env NODE_ENV=production TARGET_ENV=printer BUILD_ENV=debug webpack --mode=production", + "build-debug": "npm run build-printer-debug & npm run build-grbl-debug & npm run build-lang", + "build-grbl": "cross-env NODE_ENV=production TARGET_ENV=grbl BUILD_ENV=production webpack --mode=production", + "build-printer": "cross-env NODE_ENV=production TARGET_ENV=printer BUILD_ENV=production webpack --mode=production", + "build-prod": "npm run build-printer & npm run build-grbl & npm run build-lang", + "build": "npm run build-printer & npm run build-grbl & npm run build-printer-debug & npm run build-grbl-debug & npm run build-lang", "clean": "rm -rf dist", "grbl": "cross-env NODE_ENV=development TARGET_ENV=grbl webpack-dev-server --open --mode=development", "printer": "cross-env NODE_ENV=development TARGET_ENV=printer webpack-dev-server --open --mode=development", diff --git a/src/components/app.js b/src/components/app.js index 195ef23d..9e862f1a 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -133,7 +133,7 @@ const MainPage = () => { * Apply necessary settings */ function applyConfig(data) { - //console.log("Apply settings") + console.log("Apply settings") esp3dSettings = data document.title = esp3dSettings.Hostname if (esp3dSettings.FWTarget == "unknown") { diff --git a/src/components/dialog/index.js b/src/components/dialog/index.js index e853b3fc..0b03d157 100644 --- a/src/components/dialog/index.js +++ b/src/components/dialog/index.js @@ -224,7 +224,7 @@ const DialogPage = () => { const { showDialog } = useStoreon("showDialog") const { dialogData } = useStoreon("dialogData") if (!dialogData) return null - //console.log(dialogData) + console.log(dialogData) if (!showDialog) { disableNode(document.getElementById("mainwindow"), false) return null @@ -232,7 +232,7 @@ const DialogPage = () => { useEffect(() => { disableNode(document.getElementById("mainwindow"), true) }) - //console.log(dialogData) + console.log(dialogData) let classname = "modal d-block" let iconTitle, iconMsg let progressbar @@ -247,7 +247,6 @@ const DialogPage = () => { } if (dialogData.type == "login") { title = T("S145") - //TODO ADD PROPER FORM dialogData.message = (
diff --git a/src/components/grbl/index.js b/src/components/grbl/index.js index 238fc684..b68387a8 100644 --- a/src/components/grbl/index.js +++ b/src/components/grbl/index.js @@ -201,7 +201,7 @@ function loadImportFile() { let reader = new FileReader() reader.onload = function(e) { var contents = e.target.result - //console.log(contents) + console.log(contents) try { printerImportSettings = JSON.parse(contents) currentIndex = -1 @@ -231,7 +231,7 @@ function loadImportFile() { function cancelImport() { stopImport = true showDialog({ displayDialog: false }) - //console.log("stopping import") + console.log("stopping import") } /* @@ -268,7 +268,7 @@ function exportSettings() { } } data += "]}" - //console.log(data) + console.log(data) file = new Blob([data], { type: "application/json" }) if (window.navigator.msSaveOrOpenBlob) // IE10+ @@ -325,8 +325,8 @@ function processEventsData(type, data) { function processWSData(buffer) { processFeedRate(buffer) if (isConfigRequested) { - //console.log("config requested, processing " + buffer) - //console.log("setting size " + listrawSettings.length) + console.log("config requested, processing " + buffer) + console.log("setting size " + listrawSettings.length) if ( buffer.startsWith(configurationCmd()[2]) || buffer.startsWith(configurationCmd()[3]) @@ -575,7 +575,7 @@ function setState(entry, state) { let input = document.getElementById("printer_input_" + id) let button = document.getElementById("printer_button_" + id) if (!label || !input || !button) { - //console.log("not found" + entry.id) + console.log("not found" + entry.id) return } input.classList.remove("is-valid") diff --git a/src/components/http/index.js b/src/components/http/index.js index 5fedf602..00299e8c 100644 --- a/src/components/http/index.js +++ b/src/components/http/index.js @@ -77,7 +77,7 @@ function defaultHttpResultFn(response_text) { ) { httpCommandList[0].resultfn(response_text) } - //console.log("Success : " + response_text) + console.log("Success : " + response_text) nextCommand() } @@ -107,12 +107,10 @@ function defaultHttpErrorFn(errorcode, response_text) { * Request Login/Password */ function requestAuthentication() { - console.log("Need login password") //remove previous failed command if (httpCommandList.length > 0) { if (httpCommandList[0].id == "login") httpCommandList.shift() } - console.log(httpCommandList) showDialog({ type: "login" }) } @@ -120,7 +118,7 @@ function requestAuthentication() { * Go to next command in queries list */ function nextCommand() { - //console.log("pop " + httpCommandList[0].uri) + console.log("pop " + httpCommandList[0].uri) httpCommandList.shift() isProcessingHttpCommand = false pausePing(false) @@ -258,8 +256,6 @@ function SubmitCredentials(login, password, newpassword, timeout) { } //put command at the top of list httpCommandList.unshift(cmd) - console.log("New login") - console.log(httpCommandList) isProcessingHttpCommand = false processCommands() } @@ -269,12 +265,12 @@ function SubmitCredentials(login, password, newpassword, timeout) { */ function processCommands() { if (httpCommandList.length > 0 && !isProcessingHttpCommand) { - /*console.log( + console.log( "Processing " + httpCommandList[0].type + " command:" + httpCommandList[0].uri - )*/ + ) if ( httpCommandList[0].type == "GET" || httpCommandList[0].type == "POST" @@ -331,7 +327,7 @@ function processCommands() { ) } if (httpCommandList[0].type == "POST") { - //console.log("Post query") + console.log("Post query") console.log(httpCommandList[0].data) } currentHttpCommand.send( diff --git a/src/components/printer/files.js b/src/components/printer/files.js index b904f256..51794ab3 100644 --- a/src/components/printer/files.js +++ b/src/components/printer/files.js @@ -337,7 +337,7 @@ function processFiles(rawdata) { let data = rawdata data.trim() if (data.length == 0) return - //console.log(rawdata) + console.log(rawdata) if (isSDCheckRequested) { let response = checkSerialSDCmd() if (data.indexOf(response[1]) != -1) { diff --git a/src/components/printer/index.js b/src/components/printer/index.js index dec19719..bd3b4cb5 100644 --- a/src/components/printer/index.js +++ b/src/components/printer/index.js @@ -315,7 +315,7 @@ function isVerboseData(data) { //TODO split by FW possibilities if (typeof data == "object") { //TODO What about error message ? - //console.log(data) + console.log(data) return true } if ( @@ -488,7 +488,7 @@ function loadImportFile() { let reader = new FileReader() reader.onload = function(e) { var contents = e.target.result - //console.log(contents) + console.log(contents) try { printerImportSettings = JSON.parse(contents) currentIndex = -1 @@ -518,7 +518,7 @@ function loadImportFile() { function cancelImport() { stopImport = true showDialog({ displayDialog: false }) - //console.log("stopping import") + console.log("stopping import") } /* @@ -555,7 +555,7 @@ function exportSettings() { } } data += "]}" - //console.log(data) + console.log(data) file = new Blob([data], { type: "application/json" }) if (window.navigator.msSaveOrOpenBlob) // IE10+ @@ -796,7 +796,7 @@ function processConfigData() { } } - //console.log(listSettings) + console.log(listSettings) showDialog({ displayDialog: false, refreshPage: true }) stopTimeout() } @@ -1148,7 +1148,7 @@ function setState(entry, state) { let input = document.getElementById("printer_input_" + id) let button = document.getElementById("printer_button_" + id) if (!label || !input || !button) { - //console.log("not found" + entry.id) + console.log("not found" + entry.id) return } input.classList.remove("is-valid") diff --git a/src/components/printer/temperatures.js b/src/components/printer/temperatures.js index 300edfee..27c31b12 100644 --- a/src/components/printer/temperatures.js +++ b/src/components/printer/temperatures.js @@ -451,7 +451,7 @@ function checkValue(entry, type) { */ function updateState(entry, id) { if (typeof entry == "undefined") { - //console.log("undefined state") + console.log("undefined state") return } let type = id.split("_")[0] diff --git a/src/components/settings/esp3d.js b/src/components/settings/esp3d.js index 8fdc2209..d4b30d6f 100644 --- a/src/components/settings/esp3d.js +++ b/src/components/settings/esp3d.js @@ -548,7 +548,7 @@ function loadSettingsSuccess(responseText) { try { refreshOngoing = false esp3dFWSettings = JSON.parse(responseText) - //console.log(esp3dFWSettings) + console.log(esp3dFWSettings) showDialog({ displayDialog: false, refreshPage: true }) } catch (e) { console.log(responseText) @@ -586,7 +586,7 @@ function loadWiFiNetworksSuccess(responseText) { ) - //console.log(listnetworks) + console.log(listnetworks) for (let key in listnetworks.AP_LIST) { let sub_key = Object.keys(listnetworks.AP_LIST[key]) let sub_val = Object.values(listnetworks.AP_LIST[key]) diff --git a/src/components/translations/index.js b/src/components/translations/index.js index 6fe19faa..cc8d1fd4 100644 --- a/src/components/translations/index.js +++ b/src/components/translations/index.js @@ -65,7 +65,7 @@ function T(id) { if (typeof translatedText === "undefined") { translatedText = enLangRessource[id] if (typeof translatedText === "undefined") { - //console.log("[Translation]" + id + " is not defined!") + console.log("[Translation]" + id + " is not defined!") translatedText = id } } diff --git a/src/components/websocket/index.js b/src/components/websocket/index.js index c184736e..a8c59ae7 100644 --- a/src/components/websocket/index.js +++ b/src/components/websocket/index.js @@ -88,7 +88,7 @@ function ping(start = false) { setTimeout(ping, pingDelay) if (pingPaused) return if (webSocketClient.readyState == 1) { - //console.log("ping") + console.log("ping") webSocketClient.send("ping") } } @@ -97,7 +97,7 @@ function ping(start = false) { * Process WS terminal line */ function processWebSocketBuffer(wsBuffer) { - //console.log(wsBuffer) + console.log(wsBuffer) updateTerminal(wsBuffer) processWSData(wsBuffer) } @@ -171,7 +171,7 @@ function connectWsServer() { //On open WS webSocketClient.onopen = function(e) { reconnectCounter = 0 - //console.log("ws connection ok") + console.log("ws connection ok") ping(true) } //On close ws diff --git a/src/server/index.js b/src/server/index.js index 3f0f7b3b..023fe9b3 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -1467,6 +1467,6 @@ wss.on("connection", function(ws) { }) currentID++ ws.on("message", function(message) { - //console.log("received: %s", message) + console.log("received: %s", message) }) }) diff --git a/src/server/indexgrbl.js b/src/server/indexgrbl.js index 28f87d13..7659f369 100644 --- a/src/server/indexgrbl.js +++ b/src/server/indexgrbl.js @@ -575,6 +575,6 @@ wss.on("connection", function(ws) { }) currentID++ ws.on("message", function(message) { - //console.log("received: %s", message) + console.log("received: %s", message) }) }) diff --git a/webpack/plugins/remove-files-webpack-plugin.js b/webpack/plugins/remove-files-webpack-plugin.js index 03f74c72..b49d6d71 100644 --- a/webpack/plugins/remove-files-webpack-plugin.js +++ b/webpack/plugins/remove-files-webpack-plugin.js @@ -4,14 +4,14 @@ */ const RemoveFilesWebpackPlugin = require("remove-files-webpack-plugin") -var dist = "dist/" + process.env.TARGET_ENV +var dist = "dist/" + process.env.TARGET_ENV + "/" + process.env.BUILD_ENV const config = { before: { include: [process.env.TARGET_ENV], }, after: { - exclude: [dist + "/index.html.gz"], + exclude: [dist + "/index.html.gz"], test: [ { folder: "./" + dist, diff --git a/webpack/plugins/terser-plugin.js b/webpack/plugins/terser-plugin.js index 08256395..ffab318b 100644 --- a/webpack/plugins/terser-plugin.js +++ b/webpack/plugins/terser-plugin.js @@ -4,7 +4,7 @@ */ import TerserPlugin from "terser-webpack-plugin" - +import environment from "../environment" const config = { parallel: true, cache: false, @@ -19,6 +19,7 @@ const config = { ecma: 5, warnings: false, comparisons: false, + drop_console: process.env.BUILD_ENV == "debug" ? false:true, }, mangle: { safari10: true, diff --git a/webpack/production.js b/webpack/production.js index d401234b..230679dd 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -2,7 +2,7 @@ import merge from "webpack-merge" import environment from "./environment" import { productionPlugins, optimizationPlugins } from "./plugins" var path = require("path") -var dist = "../dist/" + process.env.TARGET_ENV +var dist = "../dist/" + process.env.TARGET_ENV + "/" + process.env.BUILD_ENV module.exports = merge(environment, { optimization: optimizationPlugins, plugins: productionPlugins,