npm install
npm run build
- Open
index.html
in browser
Last active
September 19, 2023 12:33
-
-
Save simon04/3b89aa6ca858c72110bb80dd13b4f941 to your computer and use it in GitHub Desktop.
Leaflet & webpack
This file contains hidden or 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
dist/ | |
node_modules/ |
This file contains hidden or 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
html, | |
body { | |
height: 100%; | |
padding: 0; | |
margin: 0; | |
} | |
#map { | |
z-index: 0; | |
height: 100%; | |
} |
This file contains hidden or 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" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Leaflet</title> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="./dist/app.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
import L from "leaflet"; | |
import "leaflet/dist/leaflet.css"; | |
import "./index.css"; | |
var map = L.map("map").setView([51.505, -0.09], 13); | |
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { | |
attribution: | |
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', | |
}).addTo(map); | |
L.marker([51.5, -0.09]) | |
.addTo(map) | |
.bindPopup("A pretty CSS3 popup.<br> Easily customizable.") | |
.openPopup(); |
This file contains hidden or 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
{ | |
"scripts": { | |
"build": "webpack" | |
}, | |
"dependencies": { | |
"leaflet": "^1.6.0" | |
}, | |
"devDependencies": { | |
"css-loader": "^3.4.0", | |
"file-loader": "^5.1.0", | |
"style-loader": "^1.1.1", | |
"webpack": "^4.41.4", | |
"webpack-cli": "^3.3.10", | |
"webpack-dev-server": "^3.10.1" | |
} | |
} |
This file contains hidden or 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
module.exports = { | |
mode: "production", | |
entry: "./index.js", | |
output: { | |
filename: "app.js", | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.css$/, | |
loaders: ["style-loader", "css-loader"], | |
}, | |
{ | |
test: /\.(png|svg|jpg|gif)$/, | |
use: { | |
loader: "file-loader", | |
}, | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment