Add webpack #1

Merged
hanneshdc merged 4 commits from :webpack into master 2017-11-10 09:43:53 +00:00
7 changed files with 83 additions and 16 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
clientpack/**
node_modules/**

23
.vscode/tasks.json vendored Normal file
View File

@ -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"]
}
]
}

View File

@ -28,20 +28,12 @@ clean:
rm -f ./bindata.go rm -f ./bindata.go
bindata.go: client client/* bindata.go: client client/*
rm -fr ./clientpack npm run webpack
cp -r ./client ./clientpack cat client/index.htm \
( echo ';(function() {' ; cat clientpack/dcwebui.js ; echo '})();' ) | uglifyjs -o clientpack/dcwebui.min.js -c -m --ie8 | sed -e '/bundle.js/{i <script>' -e 'r clientpack/bundle.min.js' -e 'a </script>' -e 'd}' \
lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css > clientpack/index.htm
cat clientpack/index.htm \
| sed -e '/dcwebui.css/{i <style>' -e 'r clientpack/dcwebui.min.css' -e 'a </style>' -e 'd}' \
| sed -e '/dcwebui.js/{i <script>' -e 'r clientpack/dcwebui.min.js' -e 'a </script>' -e 'd}' \
| sed -e '/socket.io-1.7.2.js/{i <script>' -e 'r clientpack/socket.io-1.7.2.js' -e 'a </script>' -e 'd}' \
> clientpack/index.packed.htm
mv clientpack/index.packed.htm clientpack/index.htm
html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm
mv 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 go-bindata -nomemcopy -nometadata -prefix clientpack clientpack
$(BINNAME).exe: bindata.go *.go $(BINNAME).exe: bindata.go *.go

View File

@ -1,5 +1,8 @@
/* dcwebui.js */ /* dcwebui.js */
require("./dcwebui.css");
require("./socket.io-1.7.2.js");
"use strict"; "use strict";
var SENTINEL_PASSWORD = "************"; var SENTINEL_PASSWORD = "************";

View File

@ -5,8 +5,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" href="./apple-touch-icon.png">
<link rel="stylesheet" href="/dcwebui.css">
<title>Loading...</title> <title>Loading...</title>
</head> </head>
<body> <body>
@ -56,7 +55,6 @@
</form> </form>
</div> </div>
<script type="text/javascript" src="/socket.io-1.7.2.js"></script> <script type="text/javascript" src="/bundle.js"></script>
<script type="text/javascript" src="/dcwebui.js"></script>
</body> </body>
</html> </html>

28
package.json Normal file
View File

@ -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": {
}
}

21
webpack.config.js Normal file
View File

@ -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
}
})
]
};