This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
91 lines (89 loc) · 2.36 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack');
const { env } = require('process');
let config = {
mode: 'development',
entry: {
app: './assets/js/app.js',
'map-ol': './assets/js/map-ol.js',
'map-maplibre': './assets/js/map-maplibre.js',
},
devtool: 'source-map',
devServer: {
port: "8080"
},
plugins: [
new HtmlWebpackPlugin({
title: 'Comparaison Maplibre et OpenLayers',
template: './src/index.html',
chunks: ['app']
}),
new HtmlWebpackPlugin({
title: 'Map OpenLayers',
template: './src/map-ol.html',
filename: "map-ol.html",
chunks: ['app', 'map-ol']
}),
new HtmlWebpackPlugin({
title: 'Map Maplibre',
template: './src/map-maplibre.html',
filename: "map-maplibre.html",
chunks: ['app', 'map-maplibre']
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new MiniCssExtractPlugin()
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, './dist'),
clean: true,
},
module: {
rules: [{
test: /\.js$/i,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.css$/i,
use: [
env.dev ? "style-loader" : MiniCssExtractPlugin.loader,
'css-loader'
],
},
{
test: /\.(sa|sc)ss$/,
use: [
"style-loader",
"css-loader",
"sass-loader",
],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
}]
},
resolve: {
alias: {
jquery: "jquery/src/jquery"
}
},
optimization: {
runtimeChunk: 'single',
},
};
module.exports = (env) => {
console.log(`Mode dev : ${env.dev}`)
if (!env.dev) {
config.plugins.push(new TerserPlugin());
config.devtool = 'eval-cheap-module-source-map';
}
return config;
}