Skip to content

Commit

Permalink
chore(build): Switch build system to use Grunt/Browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
perliedman committed Oct 3, 2014
1 parent d3dd21b commit 371c548
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .jshintrc
Expand Up @@ -7,10 +7,10 @@
// Define globals exposed by modern browsers.
"browser": true,

// Define globals exposed by jQuery.
"jquery": true,
// Define globals exposed by Node.js.
"node": true,

"globals": {"L": false, "proj4": false},
"globals": {"L": false},

/*
* ENFORCING OPTIONS
Expand Down
28 changes: 28 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,28 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
options: {
src: ['src/L.Routing.Control.js'],
dest: 'dist/leaflet-routing-machine.js',
browserifyOptions: {
standalone: 'L.Routing'
}
},
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n\n'
},
build: {
src: 'dist/leaflet-routing-machine.js',
dest: 'dist/leaflet-routing-machine.min.js'
}
}
});

grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['browserify', 'uglify']);
};
12 changes: 0 additions & 12 deletions Makefile

This file was deleted.

9 changes: 1 addition & 8 deletions examples/index.html
Expand Up @@ -10,14 +10,7 @@
<body>
<div id="map" class="map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script src="../src/L.Routing.Autocomplete.js"></script>
<script src="../src/L.Routing.Formatter.js"></script>
<script src="../src/L.Routing.ItineraryBuilder.js"></script>
<script src="../src/L.Routing.OSRM.js"></script>
<script src="../src/L.Routing.Line.js"></script>
<script src="../src/L.Routing.Itinerary.js"></script>
<script src="../src/L.Routing.Plan.js"></script>
<script src="../src/L.Routing.Control.js"></script>
<script src="../dist/leaflet-routing-machine.js"></script>
<script src="Control.Geocoder.js"></script>
<script src="index.js"></script>
</body>
Expand Down
15 changes: 12 additions & 3 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "leaflet-routing-machine",
"version": "1.0.0",
"description": "Routing for Leaflet",
"main": "dist/leaflet-routing-machine.js",
"main": "./dist/leaflet-routing-machine.js",
"directories": {
"example": "examples",
"dist": "dist"
Expand All @@ -11,7 +11,6 @@
"prepublish": "make",
"test": "echo \"Error: no test specified\" && exit 1"
},
"main": "./dist/leaflet-routing-machine.js",
"repository": {
"type": "git",
"url": "git://github.com/perliedman/leaflet-routing-machine.git"
Expand All @@ -30,8 +29,18 @@
"url": "https://github.com/perliedman/leaflet-routing-machine/issues"
},
"homepage": "https://github.com/perliedman/leaflet-routing-machine",
"browserify": {
"transform": "browserify-shim"
},
"browserify-shim": {
"leaflet": "global:L"
},
"devDependencies": {
"uglifyjs": "~2.3.6"
"browserify": "^5.12.1",
"browserify-shim": "^3.7.0",
"grunt": "^0.4.5",
"grunt-browserify": "^3.0.1",
"grunt-contrib-uglify": "^0.6.0"
},
"dependencies": {
"leaflet": "^0.7.2"
Expand Down
10 changes: 10 additions & 0 deletions src/L.Routing.Control.js
@@ -1,6 +1,14 @@
(function() {
'use strict';

var L = require('leaflet');

L.Routing = L.Routing || {};
L.extend(L.Routing, require('./L.Routing.Itinerary'));
L.extend(L.Routing, require('./L.Routing.Line'));
L.extend(L.Routing, require('./L.Routing.Plan'));
L.extend(L.Routing, require('./L.Routing.OSRM'));

L.Routing.Control = L.Routing.Itinerary.extend({
options: {
fitSelectedRoutes: true,
Expand Down Expand Up @@ -174,4 +182,6 @@
L.Routing.control = function(options) {
return new L.Routing.Control(options);
};

module.exports = L.Routing;
})();
4 changes: 4 additions & 0 deletions src/L.Routing.Formatter.js
@@ -1,6 +1,8 @@
(function() {
'use strict';

var L = require('leaflet');

L.Routing = L.Routing || {};

L.Routing.Formatter = L.Class.extend({
Expand Down Expand Up @@ -160,5 +162,7 @@
return suffix[i] ? n + suffix[i] : n + 'th';
}
});

module.exports = L.Routing;
})();

6 changes: 6 additions & 0 deletions src/L.Routing.Itinerary.js
@@ -1,7 +1,11 @@
(function() {
'use strict';

var L = require('leaflet');

L.Routing = L.Routing || {};
L.extend(L.Routing, require('./L.Routing.Formatter'));
L.extend(L.Routing, require('./L.Routing.ItineraryBuilder'));

L.Routing.Itinerary = L.Control.extend({
includes: L.Mixin.Events,
Expand Down Expand Up @@ -187,4 +191,6 @@
L.Routing.itinerary = function(router) {
return new L.Routing.Itinerary(router);
};

module.exports = L.Routing;
})();
3 changes: 3 additions & 0 deletions src/L.Routing.ItineraryBuilder.js
@@ -1,6 +1,7 @@
(function() {
'use strict';

var L = require('leaflet');
L.Routing = L.Routing || {};

L.Routing.ItineraryBuilder = L.Class.extend({
Expand Down Expand Up @@ -34,4 +35,6 @@
return row;
}
});

module.exports = L.Routing;
})();
4 changes: 4 additions & 0 deletions src/L.Routing.Line.js
@@ -1,6 +1,8 @@
(function() {
'use strict';

var L = require('leaflet');

L.Routing = L.Routing || {};

L.Routing.Line = L.LayerGroup.extend({
Expand Down Expand Up @@ -127,4 +129,6 @@
L.Routing.line = function(route, options) {
return new L.Routing.Line(route, options);
};

module.exports = L.Routing;
})();
4 changes: 4 additions & 0 deletions src/L.Routing.OSRM.js
@@ -1,6 +1,8 @@
(function() {
'use strict';

var L = require('leaflet');

// Ignore camelcase naming for this file, since OSRM's API uses
// underscores.
/* jshint camelcase: false */
Expand Down Expand Up @@ -278,4 +280,6 @@
L.Routing.osrm = function(options) {
return new L.Routing.OSRM(options);
};

module.exports = L.Routing;
})();
6 changes: 5 additions & 1 deletion src/L.Routing.Plan.js
@@ -1,14 +1,16 @@
(function() {
'use strict';

var Waypoint = L.Class.extend({
var L = require('leaflet'),
Waypoint = L.Class.extend({
initialize: function(latLng, name) {
this.latLng = latLng;
this.name = name;
}
});

L.Routing = L.Routing || {};
L.extend(L.Routing, require('./L.Routing.Autocomplete'));

L.Routing.Plan = L.Class.extend({
includes: L.Mixin.Events,
Expand Down Expand Up @@ -386,4 +388,6 @@
L.Routing.plan = function(waypoints, options) {
return new L.Routing.Plan(waypoints, options);
};

module.exports = L.Routing;
})();
4 changes: 0 additions & 4 deletions src/post.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/pre.js

This file was deleted.

0 comments on commit 371c548

Please sign in to comment.