forked from betagouv/eva
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
124 lines (119 loc) · 3.34 KB
/
webpack.config.js
File metadata and controls
124 lines (119 loc) · 3.34 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const webpack = require('webpack');
const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
entry: {
competencesPro: path.resolve(__dirname, 'src/app/index.js'),
situationControle: path.resolve(__dirname, 'src/app/situationControle.js'),
situationInventaire: path.resolve(__dirname, 'src/app/situationInventaire.js'),
restitutionSituationInventaire: path.resolve(__dirname, 'src/app/restitutionSituationInventaire.js')
},
output: {
path: path.resolve(__dirname, 'public'),
filename: 'js/[name].js',
publicPath: '/' // public URL of the output directory when referenced in a browser
},
resolve: {
alias: {
accueil: path.resolve(__dirname, 'src/situations/accueil/'),
commun: path.resolve(__dirname, 'src/situations/commun/'),
controle: path.resolve(__dirname, 'src/situations/controle/'),
inventaire: path.resolve(__dirname, 'src/situations/inventaire/'),
src: path.resolve(__dirname, 'src/')
}
},
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true
}
}
}
},
module: {
rules: [
{
include: [path.resolve(__dirname, 'src/app')],
loader: 'babel-loader',
options: {
plugins: ['@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-object-rest-spread'],
presets: [
[
'@babel/env',
{
modules: false
}
]
]
},
test: /\.js$/
},
{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.(png|jpg|gif|mp3)$/i,
use: [
{
loader: 'url-loader',
options: {
name: '[name].[ext]?[sha512:hash:base64:7]',
outputPath: 'assets',
limit: 8192
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new HtmlWebpackPlugin({
filename: 'index.html',
hash: true,
template: path.resolve(__dirname, 'src/public/template_index.html'),
chunks: ['competencesPro'],
inject: 'head'
}),
new HtmlWebpackPlugin({
filename: 'controle.html',
hash: true,
template: path.resolve(__dirname, 'src/public/template_index.html'),
chunks: ['situationControle'],
inject: 'head'
}),
new HtmlWebpackPlugin({
filename: 'inventaire.html',
hash: true,
template: path.resolve(__dirname, 'src/public/template_index.html'),
chunks: ['situationInventaire'],
inject: 'head'
}),
new HtmlWebpackPlugin({
filename: 'restitution.html',
hash: true,
template: path.resolve(__dirname, 'src/public/template_index.html'),
chunks: ['restitutionSituationInventaire'],
inject: 'head'
}),
new webpack.ProvidePlugin({ jQuery: 'jquery' })
],
devServer: {
contentBase: './src/public',
port: 7700
}
};