Skip to content

Commit b600cad

Browse files
committed
demos: upgrade to webpack 5
1 parent baa68b1 commit b600cad

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

demo-webpack/index.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
<head>
44
<title>Leaflet Control Geocoder</title>
55
<meta charset="utf-8" />
6-
<link rel="stylesheet" href="./node_modules/leaflet/dist/leaflet.css" />
7-
<link
8-
rel="stylesheet"
9-
href="./node_modules/leaflet-control-geocoder/dist/Control.Geocoder.css"
10-
/>
6+
<link rel="stylesheet" href="./dist/leaflet.css" />
117
</head>
128
<body>
139
<div id="map" style="width: 600px; height: 400px;"></div>
14-
<script src="./bundle.js"></script>
10+
<script src="./dist/leaflet.js"></script>
1511
</body>
1612
</html>

demo-webpack/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import L from 'leaflet';
22
import 'leaflet-control-geocoder';
33

4+
import 'leaflet/dist/leaflet.css';
5+
import 'leaflet-control-geocoder/dist/Control.Geocoder.css';
6+
47
var map = L.map('map').setView([0, 0], 2);
58
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
69
attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'

demo-webpack/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"leaflet-control-geocoder": "^1.8.0"
1010
},
1111
"devDependencies": {
12-
"webpack": "^4.33.0",
13-
"webpack-cli": "^3.3.3"
12+
"css-loader": "^5.0.0",
13+
"file-loader": "^6.2.0",
14+
"mini-css-extract-plugin": "^1.2.1",
15+
"webpack": "^5.3.0",
16+
"webpack-cli": "^4.1.0"
1417
}
1518
}

demo-webpack/webpack.config.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
/* eslint-env node */
2+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3+
24
module.exports = {
35
mode: 'production',
4-
entry: './main.js',
6+
entry: {
7+
leaflet: './main.js'
8+
},
59
output: {
6-
filename: './bundle.js'
10+
publicPath: ''
11+
},
12+
plugins: [new MiniCssExtractPlugin()],
13+
14+
module: {
15+
rules: [
16+
{
17+
test: /\.css$/,
18+
use: [MiniCssExtractPlugin.loader, 'css-loader']
19+
},
20+
{
21+
test: /\.(png|gif)$/,
22+
use: ['file-loader']
23+
}
24+
]
725
}
826
};

0 commit comments

Comments
 (0)