Skip to content

Commit

Permalink
New webpack-based build system (#6)
Browse files Browse the repository at this point in the history
* Introducing WebPack build stack

* core examples build implemented

* browser build enabled

* compile in css too

* cleaning from old closure code

* removing skydome.jpg

* introducing import-based build

* more clean global namespace export

* geographiclib and proj4 as external libraries

* README update

* Fixing all demos

* README update
  • Loading branch information
jachym authored Apr 5, 2017
1 parent 6b711a6 commit 721a765
Show file tree
Hide file tree
Showing 82 changed files with 739 additions and 9,582 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presents": ["es2015"],
"plugins": ["babel-plugin-add-module-exports"]
}
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"ecmaFeatures": {
"globalReturn": true,
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"globals": {
"document": false,
"escape": false,
"navigator": false,
"unescape": false,
"window": false,
"describe": true,
"before": true,
"it": true,
"expect": true,
"sinon": true
},
"parser": "babel-eslint",
"plugins": [],
"rules": {
// ... lots of lots of rules here
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
build/*
node_modules
build/*
build/*.js
build/*.css
.project
*.un~
*.sw*
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,31 @@

## Documentation
* [Melown API](https://github.com/Melown/melown-js/wiki/Melown-API)

## Install

```
npm install
```

(`yarn install` will be ready soon)

## Build (constantly)

```
node_modules/.bin/webpack --watch
```

## Build compressed version

```
NODE_ENV=production node_modules/.bin/webpack
```

## Run dev server

```
node_modules/.bin/webpack-dev-server --inline
```

And go to http://localhost:8080/demos/core/basic/
9 changes: 4 additions & 5 deletions demos/browser/basic/demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

function startDemo() {
var browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json"
(function startDemo() {
var browser = Melown.MapBrowser('map-div', {
map: 'https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json'
});
}
})();
11 changes: 6 additions & 5 deletions demos/browser/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
5 changes: 2 additions & 3 deletions demos/browser/flights/demo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

var browser = null;
var ui = null;
var list = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 3764, 90 ]
Expand All @@ -19,7 +18,7 @@ function startDemo() {

list = panel.getElement("panel");
list.on("change", onFlyToNewDestination);
}
})();

function onFlyToNewDestination() {
switch (list.getElement().elements["destination"].value) {
Expand Down
11 changes: 6 additions & 5 deletions demos/browser/flights/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>


<style>
Expand All @@ -22,8 +22,9 @@

</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/flights/skydome.jpg
Binary file not shown.
5 changes: 2 additions & 3 deletions demos/browser/hit-surface/demo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

var browser = null;
var pointTexture = null;
var clickCoords = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ]
Expand All @@ -16,7 +15,7 @@ function startDemo() {
browser.getMapElement().on('mousedown', onMouseDown);

loadTexture();
}
})();

function loadTexture() {
//load icon used for displaing hit point
Expand Down
11 changes: 6 additions & 5 deletions demos/browser/hit-surface/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/hit-surface/skydome.jpg
Binary file not shown.
7 changes: 3 additions & 4 deletions demos/browser/lines-and-images/demo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

var browser = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 1764, 90 ]
});

browser.on("map-loaded", onMapLoaded);
loadImage();
}
})();

var demoTexture = null;

Expand Down Expand Up @@ -65,4 +64,4 @@ function onCustomRender() {
}




11 changes: 6 additions & 5 deletions demos/browser/lines-and-images/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/lines-and-images/skydome.jpg
Binary file not shown.
7 changes: 3 additions & 4 deletions demos/browser/meshes-hit-test/demo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

var browser = null;
var woodTexture = null;
var pointTexture = null;
var cubeMesh = null;
var clickCoords = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ]
Expand All @@ -21,11 +20,11 @@ function startDemo() {

//create cube mesh
createCube();
}
})();

function loadTextures() {
//load texture used for cubes
var woodImage = Melown.Http.imageFactory("./wood.png",
var woodImage = Melown.Http.imageFactory("/demos/images/wood.png",
(function(){
woodTexture = browser.getRenderer().createTexture({ "source": woodImage });
}).bind(this)
Expand Down
11 changes: 6 additions & 5 deletions demos/browser/meshes-hit-test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/meshes-hit-test/skydome.jpg
Binary file not shown.
7 changes: 3 additions & 4 deletions demos/browser/meshes/demo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

var browser = null;
var woodTexture = null;
var cubeMesh = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json",
position : [ "obj", 1683559, 6604129, "float", 0, -13, -58, 0, 964, 90 ]
Expand All @@ -17,11 +16,11 @@ function startDemo() {

//create cube mesh
createCube();
}
})();

function loadTexture() {
//load texture used for cubes
var woodImage = Melown.Http.imageFactory("./wood.png",
var woodImage = Melown.Http.imageFactory("/demos/images/wood.png",
(function(){
woodTexture = browser.getRenderer().createTexture({ "source": woodImage });
}).bind(this)
Expand Down
11 changes: 6 additions & 5 deletions demos/browser/meshes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>
</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/meshes/skydome.jpg
Binary file not shown.
5 changes: 2 additions & 3 deletions demos/browser/view-switch/demo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

var browser = null;
var ui = null;
var button = null;

function startDemo() {
(function startDemo() {
browser = Melown.MapBrowser("map-div", {
map : "https://demo.test.mlwn.se/public-maps/grand-ev/mapConfig.json"
});
Expand All @@ -16,7 +15,7 @@ function startDemo() {

button = panel.getElement("switch");
button.on("change", onSwitchView);
}
})();

function onSwitchView() {
if (button.getElement().checked) {
Expand Down
11 changes: 6 additions & 5 deletions demos/browser/view-switch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<head>
<title>Vadstena Map Viewer</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../../../build/melown-browser.css" />
<script type="text/javascript" src="../../../build/melown-browser.js"></script>
<script type="text/javascript" src="./demo.js"></script>
<link rel="stylesheet" type="text/css" href="/build/melown-browser.css" />
<script src="/webpack-dev-server.js"></script>
<script type="text/javascript" src="/build/melown-browser.js"></script>


<style>
Expand All @@ -22,8 +22,9 @@

</head>

<body style = "padding: 0; margin: 0;" onload="startDemo()">
<body style = "padding: 0; margin: 0;">
<div id="map-div" style="width:100%; height:100%;">
</div>
<script type="text/javascript" src="demo.js"></script>
</body>
</html>
</html>
Binary file removed demos/browser/view-switch/skydome.jpg
Binary file not shown.
Loading

0 comments on commit 721a765

Please sign in to comment.