Skip to content

Commit

Permalink
demos: upgrade to webpack 5
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Oct 28, 2020
1 parent baa68b1 commit b600cad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
8 changes: 2 additions & 6 deletions demo-webpack/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
<head>
<title>Leaflet Control Geocoder</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="./node_modules/leaflet/dist/leaflet.css" />
<link
rel="stylesheet"
href="./node_modules/leaflet-control-geocoder/dist/Control.Geocoder.css"
/>
<link rel="stylesheet" href="./dist/leaflet.css" />
</head>
<body>
<div id="map" style="width: 600px; height: 400px;"></div>
<script src="./bundle.js"></script>
<script src="./dist/leaflet.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions demo-webpack/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import L from 'leaflet';
import 'leaflet-control-geocoder';

import 'leaflet/dist/leaflet.css';
import 'leaflet-control-geocoder/dist/Control.Geocoder.css';

var map = L.map('map').setView([0, 0], 2);
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
Expand Down
7 changes: 5 additions & 2 deletions demo-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"leaflet-control-geocoder": "^1.8.0"
},
"devDependencies": {
"webpack": "^4.33.0",
"webpack-cli": "^3.3.3"
"css-loader": "^5.0.0",
"file-loader": "^6.2.0",
"mini-css-extract-plugin": "^1.2.1",
"webpack": "^5.3.0",
"webpack-cli": "^4.1.0"
}
}
22 changes: 20 additions & 2 deletions demo-webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/* eslint-env node */
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
mode: 'production',
entry: './main.js',
entry: {
leaflet: './main.js'
},
output: {
filename: './bundle.js'
publicPath: ''
},
plugins: [new MiniCssExtractPlugin()],

module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(png|gif)$/,
use: ['file-loader']
}
]
}
};

0 comments on commit b600cad

Please sign in to comment.