forked from urlaubsverwaltung/urlaubsverwaltung
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
147 lines (137 loc) · 4.78 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserJSPlugin = require("terser-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
devtool: false,
entry: {
polyfill: '@babel/polyfill',
'date-fns-localized': './src/main/webapp/bundles/date-fns-localized.js',
login: './src/main/webapp/bundles/login.js',
app_detail: './src/main/webapp/bundles/app-detail.js',
app_form: './src/main/webapp/bundles/app-form.js',
app_list: './src/main/webapp/bundles/app-list.js',
app_statistics: './src/main/webapp/bundles/app-statistics.js',
common: './src/main/webapp/bundles/common.js',
person_overview: './src/main/webapp/bundles/person-overview.js',
person_form: './src/main/webapp/bundles/person-form.js',
sick_note_form: './src/main/webapp/bundles/sick-note-form.js',
sick_note: './src/main/webapp/bundles/sick-note.js',
sick_note_convert: './src/main/webapp/bundles/sick-note-convert.js',
sick_notes: './src/main/webapp/bundles/sick-notes.js',
staff_view: './src/main/webapp/bundles/staff-view.js',
vacation_overview: './src/main/webapp/bundles/vacation-overview.js',
department_form: './src/main/webapp/bundles/department-form.js',
department_list: './src/main/webapp/bundles/department-list.js',
overtime_form: './src/main/webapp/bundles/overtime-form.js',
settings_form: './src/main/webapp/bundles/settings-form.js',
account_form: './src/main/webapp/bundles/account-form.js',
workingtime_form: './src/main/webapp/bundles/workingtime-form.js',
absence_overview: './src/main/webapp/bundles/absence_overview.js',
},
output: {
path: path.resolve(__dirname, 'target/classes/static/assets'),
filename: '[name].min.js',
publicPath: '/assets/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
],
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"less-loader",
],
},
{
test: /\.(woff(2)?|ttf|eot|svg)$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}]
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
}
}
]
}
]
},
plugins: [
// https://webpack.js.org/guides/caching/#module-identifiers
// include HashedModuleIdsPlugin so that file hashes don't change unexpectedly
new webpack.HashedModuleIdsPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new MiniCssExtractPlugin({
filename: "../assets/[name].css",
})
],
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 1024,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
if (/node_modules\/jquery-ui\/ui\/i18n/.test(module.context)) {
const locale = module.resource.match(/datepicker-(\w\w)/)[1];
// build separate bundles for jquery-ui-datepicker
// which can be included on demand in the view templates
// or used as dynamic import and handled by webpack
return `npm.${packageName}.datepicker.${locale}`;
}
if (packageName === 'date-fns') {
// build separate bundles for dateFn locales
// which can be included on demand in the view templates
// or used as dynamic import and handled by webpack
const dateFnLocaleMatch = module.context.match(/node_modules\/date-fns\/locale\/((?!en)(?!_)\w\w)/);
if (dateFnLocaleMatch) {
const locale = dateFnLocaleMatch[1];
return `npm.${packageName}.${locale}`;
}
}
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
minimizer: [
new TerserJSPlugin({}),
new OptimizeCSSAssetsPlugin({})
]
},
};