Created
September 20, 2016 17:58
-
-
Save thejmazz/16358f6327effd708e84bb88ffe75632 to your computer and use it in GitHub Desktop.
mapbox-gl-js + webpack issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// thanks sleepycat https://github.com/sleepycat/mapboxgl-webpack-example | |
import mapboxgl from 'mapbox-gl' | |
mapboxgl.accessToken = 'pk.eyJ1IjoibWlrZXdpbGxpYW1zb24iLCJhIjoibzRCYUlGSSJ9.QGvlt6Opm5futGhE5i-1kw'; | |
var map = new mapboxgl.Map({ | |
container: 'map', // container id | |
style: 'mapbox://styles/mapbox/streets-v8', //stylesheet location | |
center: [-74.50, 40], // starting position | |
zoom: 9 // starting zoom | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<title></title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.14.2/mapbox-gl.css' rel='stylesheet' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script src="bundle.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mapbox-gl-js-webpack", | |
"version": "1.0.0", | |
"description": "Example showing how to use mapbox-gl-js with webpack", | |
"main": "app.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "MIT", | |
"devDependencies": { | |
"babel-loader": "^6.2.5", | |
"babel-preset-es2015": "^6.14.0", | |
"json-loader": "^0.5.4", | |
"transform-loader": "^0.2.3", | |
"webpack": "^1.13.2", | |
"webworkify-webpack": "^1.1.7" | |
}, | |
"dependencies": { | |
"mapbox-gl": "^0.24.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
module.exports = { | |
entry: './app.js', | |
devtool: 'source-map', | |
output: { | |
path: './', | |
filename: 'bundle.js', | |
}, | |
resolve: { | |
alias: { | |
'webworkify': 'webworkify-webpack', | |
// Uncomment this to make it work | |
// 'gl-matrix': path.resolve('./node_modules/gl-matrix/dist/gl-matrix.js') | |
} | |
}, | |
module: { | |
loaders: [{ | |
test: /\.jsx?$/, | |
loader: 'babel', | |
query: { | |
presets: ["es2015"] | |
} | |
}, { | |
test: /\.json$/, | |
loader: 'json-loader' | |
}, { | |
test: /\.js$/, | |
include: path.resolve('node_modules/mapbox-gl-shaders/index.js'), | |
loader: 'transform/cacheable?brfs' | |
}], | |
postLoaders: [{ | |
include: /node_modules\/mapbox-gl-shaders/, | |
loader: 'transform', | |
query: 'brfs' | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment