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/.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/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/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 new file mode 100644 index 0000000..0e03939 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "nmdc-webfrontend", + "version": "1.0.0", + "description": "", + "main": "s", + "scripts": { + "webpack": "webpack" + }, + "repository": { + "type": "git", + "url": "https://git.ivysaur.me/code.ivysaur.me/nmdc-webfrontend" + }, + "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", + "typescript": "^2.6.1", + "webpack": "^3.8.1" + }, + "devDependencies": { + } +} 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