├── .gitignore ├── README.md ├── app.js ├── index.html ├── package.json ├── webpack.config.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a minimal example of using Webpack and Mapbox-gl-js together. It 2 | is part of the [blog post of the same 3 | name](https://mikewilliamson.wordpress.com/2016/02/24/using-mapbox-gl-and-webpack-together/). 4 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | import mapboxgl from 'mapbox-gl' 2 | 3 | mapboxgl.accessToken = 'pk.eyJ1IjoibWlrZXdpbGxpYW1zb24iLCJhIjoibzRCYUlGSSJ9.QGvlt6Opm5futGhE5i-1kw'; 4 | var map = new mapboxgl.Map({ 5 | container: 'map', // container id 6 | style: 'mapbox://styles/mapbox/streets-v8', //stylesheet location 7 | center: [-74.50, 40], // starting position 8 | zoom: 9 // starting zoom 9 | }); 10 | 11 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mapboxgl-webpack", 3 | "version": "1.0.0", 4 | "description": "an example of using mapboxgl and webpack together", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Mike Williamson", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "babel-core": "^6.9.1", 13 | "babel-loader": "^6.2.4", 14 | "babel-preset-es2015": "^6.9.0", 15 | "babel-preset-stage-0": "^6.5.0", 16 | "json-loader": "^0.5.4", 17 | "mapbox-gl": "^0.20.0", 18 | "transform-loader": "^0.2.3", 19 | "webpack": "^1.13.1", 20 | "webworkify": "^1.2.1", 21 | "webworkify-webpack": "^1.1.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack') 2 | var path = require('path') 3 | 4 | module.exports = { 5 | entry: './app.js', 6 | output: { path: __dirname, filename: 'bundle.js' }, 7 | resolve: { 8 | extensions: ['', '.js'], 9 | alias: { 10 | webworkify: 'webworkify-webpack', 11 | 'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js') 12 | } 13 | }, 14 | module: { 15 | loaders: [ 16 | { 17 | test: /\.jsx?$/, 18 | loader: 'babel', 19 | exclude: /node_modules/, 20 | query: { 21 | presets: ['es2015', 'stage-0'] 22 | } 23 | }, 24 | { 25 | test: /\.json$/, 26 | loader: 'json-loader' 27 | }, 28 | { 29 | test: /\.js$/, 30 | include: path.resolve(__dirname, 'node_modules/webworkify/index.js'), 31 | loader: 'worker' 32 | }, 33 | { 34 | test: /mapbox-gl.+\.js$/, 35 | loader: 'transform/cacheable?brfs' 36 | } 37 | ] 38 | }, 39 | }; 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mike Williamson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------