-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (80 loc) · 2.28 KB
/
webpack.config.js
File metadata and controls
83 lines (80 loc) · 2.28 KB
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
const path = require ('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); //ici on declare le plug-in que l'on a installé
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.bundle.js',
clean: true
},
optimization:{
minimize : true,
minimizer:[
new TerserPlugin({
parallel: true,
}),
new ImageMinimizerPlugin({
generator: [
{
type: 'asset',
implementation: ImageMinimizerPlugin.imageminGenerate,
preset: 'webp',
options: {
plugins: ["imagemin-webp"]
}
}
]
})
]
},
module: {
rules:[
{
test: /\.js$/, //antislash devant point pour bien dire qu'on cherche un .
exclude: /node_modules/,
use:{
loader: "babel-loader",
}
},
{
test: /\.css$/,
use:[
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
plugins:[
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
}),
new MiniCssExtractPlugin({
filename: "style-min.css",
}),
new CopyPlugin({
patterns: [
{
from: "./src/assets/images/",
to: "./assets/imzges/"
}
]
})
],
devtool: "source-map", //minifie le css mais garde la possibilité d'afficher propre
mode: 'development',
devServer: {
open: true, //ouvre le navigateur par défaut
//watchFiles: ['./src/**'], //ecoute tout ce qu'il y a dans src
port: 3000, //pour ne pas mettre 80 comme laragon
hot: true, //surveille les maj
static: {
directory: path.join(__dirname, 'dist')
},
liveReload: true
}
}