From fcddbf85b050fa39749f9cb54a5497d9d34b0e77 Mon Sep 17 00:00:00 2001 From: hanneshdc Date: Fri, 10 Nov 2017 19:56:24 +1300 Subject: [PATCH 1/4] Add package.json and gitignore --- .gitignore | 2 ++ package.json | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .gitignore create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6136a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +clientpack/** +node_modules/** \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4afcdaa --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "nmdc-webfrontend", + "version": "1.0.0", + "description": "", + "main": "s", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://git.ivysaur.me/code.ivysaur.me/nmdc-webfrontend" + }, + "author": "", + "license": "ISC", + "dependencies": { + "html-minifier": "^3.5.6", + "less": "^2.7.3", + "less-plugin-clean-css": "^1.5.1", + "uglify-js": "^3.1.8" + } +} -- 2.40.1 From 29bcf75470ca1ffab8d5aaec98a0669515c81adc Mon Sep 17 00:00:00 2001 From: hanneshdc Date: Fri, 10 Nov 2017 20:38:47 +1300 Subject: [PATCH 2/4] Install webpack and create a webpack config --- .vscode/tasks.json | 23 +++++++++++++++++++++++ client/dcwebui.js | 3 +++ client/index.htm | 6 ++---- package.json | 7 ++++++- webpack.config.js | 21 +++++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 webpack.config.js diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..eab2057 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "tasks": [ + { + "taskName": "install", + "args": ["install"] + }, + { + "taskName": "update", + "args": ["update"] + }, + { + "taskName": "test", + "args": ["run", "test"] + } + ] +} \ No newline at end of file diff --git a/client/dcwebui.js b/client/dcwebui.js index 810659c..c73bf9d 100644 --- a/client/dcwebui.js +++ b/client/dcwebui.js @@ -1,5 +1,8 @@ /* dcwebui.js */ + require("./dcwebui.css"); + require("./socket.io-1.7.2.js"); + "use strict"; var SENTINEL_PASSWORD = "************"; diff --git a/client/index.htm b/client/index.htm index bb3ae4f..9bf1e17 100644 --- a/client/index.htm +++ b/client/index.htm @@ -5,8 +5,7 @@ - - + Loading... @@ -56,7 +55,6 @@ - - + diff --git a/package.json b/package.json index 4afcdaa..1131dce 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "s", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "webpack && cp client/index.htm clientpack" }, "repository": { "type": "git", @@ -13,9 +13,14 @@ "author": "", "license": "ISC", "dependencies": { + "css-loader": "^0.28.7", "html-minifier": "^3.5.6", "less": "^2.7.3", "less-plugin-clean-css": "^1.5.1", + "style-loader": "^0.19.0", "uglify-js": "^3.1.8" + }, + "devDependencies": { + "webpack": "^3.8.1" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..d14067f --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,21 @@ +var webpack = require("webpack"); + +module.exports = { + entry: "./client/dcwebui.js", + output: { + path: __dirname, + filename: "clientpack/bundle.js" + }, + module: { + loaders: [ + { test: /\.css$/, loader: "style-loader!css-loader" } + ] + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }) + ] +}; \ No newline at end of file -- 2.40.1 From ab89f5f93f0603c795dba86e402356908cb325ed Mon Sep 17 00:00:00 2001 From: hanneshdc Date: Fri, 10 Nov 2017 20:45:31 +1300 Subject: [PATCH 3/4] Remove from code from makefile that is now handled by webpack --- Makefile | 16 ++++------------ package.json | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3827c2c..1c71bd0 100644 --- a/Makefile +++ b/Makefile @@ -28,20 +28,12 @@ clean: rm -f ./bindata.go bindata.go: client client/* - rm -fr ./clientpack - cp -r ./client ./clientpack - ( echo ';(function() {' ; cat clientpack/dcwebui.js ; echo '})();' ) | uglifyjs -o clientpack/dcwebui.min.js -c -m --ie8 - lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css - cat clientpack/index.htm \ - | sed -e '/dcwebui.css/{i ' -e 'd}' \ - | sed -e '/dcwebui.js/{i ' -e 'd}' \ - | sed -e '/socket.io-1.7.2.js/{i ' -e 'd}' \ - > clientpack/index.packed.htm - mv clientpack/index.packed.htm clientpack/index.htm + npm run webpack + cat client/index.htm \ + | sed -e '/bundle.js/{i ' -e 'd}' \ + > clientpack/index.htm html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm mv clientpack/index.min.htm clientpack/index.htm - rm ./clientpack/*.js - rm ./clientpack/*.css go-bindata -nomemcopy -nometadata -prefix clientpack clientpack $(BINNAME).exe: bindata.go *.go diff --git a/package.json b/package.json index 1131dce..2df1859 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "s", "scripts": { - "build": "webpack && cp client/index.htm clientpack" + "webpack": "webpack" }, "repository": { "type": "git", -- 2.40.1 From 8364e9a14625ad0f4d4660e295c9b8589db5652a Mon Sep 17 00:00:00 2001 From: hanneshdc Date: Fri, 10 Nov 2017 21:03:58 +1300 Subject: [PATCH 4/4] Add typescript and typescript loader --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2df1859..0e03939 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,16 @@ "author": "", "license": "ISC", "dependencies": { + "awesome-typescript-loader": "^3.3.0", "css-loader": "^0.28.7", "html-minifier": "^3.5.6", "less": "^2.7.3", "less-plugin-clean-css": "^1.5.1", "style-loader": "^0.19.0", - "uglify-js": "^3.1.8" + "uglify-js": "^3.1.8", + "typescript": "^2.6.1", + "webpack": "^3.8.1" }, "devDependencies": { - "webpack": "^3.8.1" } } -- 2.40.1