-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
265 lines (241 loc) · 8.43 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2021 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
// const webpack = require('webpack');
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
// const CopyWebpackPlugin = require('copy-webpack-plugin');
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const glob = require('glob');
// const path = require('path');
// const libOutputPath = 'public/lib';
// /*
// * GLPI core files build configuration.
// */
// var glpiConfig = {
// entry: {
// 'glpi': path.resolve(__dirname, 'js/main.js'),
// },
// output: {
// filename: '[name].js',
// path: path.resolve(__dirname, 'public/build'),
// },
// };
// /*
// * External libraries files build configuration.
// */
// var libsConfig = {
// entry: function () {
// // Create an entry per *.js file in lib/bundle directory.
// // Entry name will be name of the file (without ext).
// var entries = {};
// let files = glob.sync(path.resolve(__dirname, 'lib/bundles') + '/!(*.min).js');
// files.forEach(function (file) {
// entries[path.basename(file, '.js')] = file;
// });
// return entries;
// },
// output: {
// filename: '[name].js',
// path: path.resolve(__dirname, libOutputPath),
// publicPath: '',
// },
// module: {
// rules: [
// {
// // Load scripts with no compilation for packages that are directly providing "dist" files.
// // This prevents useless compilation pass and can also
// // prevents incompatibility issues with the webpack require feature.
// // It also removes existing sourcemaps that cannot be used correctly.
// test: /\.js$/,
// include: [
// path.resolve(__dirname, 'node_modules/@fullcalendar'),
// path.resolve(__dirname, 'node_modules/codemirror'),
// path.resolve(__dirname, 'node_modules/cystoscape'),
// path.resolve(__dirname, 'node_modules/cytoscape-context-menus'),
// path.resolve(__dirname, 'node_modules/gridstack'),
// path.resolve(__dirname, 'node_modules/jquery-migrate'),
// path.resolve(__dirname, 'node_modules/jstree'),
// path.resolve(__dirname, 'node_modules/photoswipe'),
// path.resolve(__dirname, 'node_modules/rrule'),
// path.resolve(__dirname, 'vendor/blueimp/jquery-file-upload'),
// ],
// use: ['script-loader', 'strip-sourcemap-loader'],
// },
// {
// // Build styles
// test: /\.css$/,
// use: [MiniCssExtractPlugin.loader, 'css-loader'],
// },
// {
// // Copy images and fonts
// test: /\.((gif|png|jp(e?)g)|(eot|ttf|svg|woff2?))$/,
// type: 'asset/resource',
// generator: {
// filename: function (pathData) {
// // Keep only relative path
// var sanitizedPath = path.relative(__dirname, pathData.filename);
// // Sanitize name
// sanitizedPath = sanitizedPath.replace(/[^\\/\w-.]/, '');
// // Remove the first directory (lib, node_modules, ...) and empty parts
// // and replace directory separator by '/' (windows case)
// sanitizedPath = sanitizedPath.split(path.sep)
// .filter(function (part, index) {
// return '' != part && index != 0;
// }).join('/');
// return sanitizedPath;
// },
// },
// },
// ],
// },
// plugins: [
// new webpack.ProvidePlugin(
// {
// process: 'process/browser', // required in util.js (indirect dependency of file-type.js)
// Buffer: ['buffer', 'Buffer'], // required in file-type.js
// }
// ),
// new webpack.NormalModuleReplacementPlugin(
// /node:/,
// (resource) => {
// const mod = resource.request.replace(/^node:/, '');
// switch (mod) {
// case 'buffer':
// resource.request = 'buffer';
// break;
// case 'stream':
// resource.request = 'readable-stream';
// break;
// default:
// throw new Error(`Not found ${mod}`);
// }
// }
// ),
// new CleanWebpackPlugin(
// {
// cleanOnceBeforeBuildPatterns: [
// path.join(process.cwd(), libOutputPath + '/**/*'),
// ]
// }
// ), // Clean lib dir content
// new MiniCssExtractPlugin(), // Extract styles into CSS files
// ],
// resolve: {
// // Use only main file in requirement resolution as we do not yet handle modules correctly
// mainFields: [
// 'main',
// ],
// alias: {
// 'stream': 'stream-browserify',
// 'os': 'os-browserify',
// 'tty': 'tty-browserify',
// },
// },
// };
// var libs = {
// '@fullcalendar': [
// {
// context: 'core',
// from: 'locales/*.js',
// }
// ],
// 'flatpickr': [
// {
// context: 'dist',
// from: 'l10n/*.js',
// },
// {
// context: 'dist',
// from: 'themes/*.css',
// }
// ],
// 'jquery-ui': [
// {
// context: 'ui',
// from: 'i18n/*.js',
// }
// ],
// 'select2': [
// {
// context: 'dist',
// from: 'js/i18n/*.js',
// }
// ],
// 'tinymce': [
// {
// from: 'skins/**/*',
// }
// ],
// 'tinymce-i18n': [
// {
// from: 'langs/*.js',
// }
// ],
// };
// for (let packageName in libs) {
// let libPackage = libs[packageName];
// let to = libOutputPath + '/' + packageName.replace(/^@/, ''); // remove leading @ in case of prefixed package
// let copyPatterns = [];
// for (let e = 0; e < libPackage.length; e++) {
// let packageEntry = libPackage[e];
// let context = 'node_modules/' + packageName;
// if (Object.prototype.hasOwnProperty.call(packageEntry, 'context')) {
// context += '/' + packageEntry.context;
// }
// let copyParams = {
// context: path.resolve(__dirname, context),
// from: packageEntry.from,
// to: path.resolve(__dirname, to),
// toType: 'dir',
// };
// if (Object.prototype.hasOwnProperty.call(packageEntry, 'ignore')) {
// copyParams.ignore = packageEntry.ignore;
// }
// copyPatterns.push(copyParams);
// }
// libsConfig.plugins.push(new CopyWebpackPlugin({patterns:copyPatterns}));
// }
// module.exports = function() {
// var configs = [glpiConfig, libsConfig];
// for (let config of configs) {
// config.mode = 'none'; // Force 'none' mode, as optimizations will be done on release process
// config.devtool = 'source-map'; // Add sourcemap to files
// // Limit verbosity to only usefull information
// config.stats = {
// all: false,
// errors: true,
// errorDetails: true,
// warnings: true,
// entrypoints: true,
// timings: true,
// };
// }
// return configs;
// };