Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
executable file
·55 lines (52 loc) · 1.69 KB
/
Copy pathwebpack.config.js
File metadata and controls
executable file
·55 lines (52 loc) · 1.69 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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
/*
* Demo client (IGNF/validator-api-client) : the built bundle and its static files (css, fonts,
* images) are copied in public/ and loaded by templates/demo.html.twig.
*/
const clientDir = path.dirname(require.resolve('@ignf/validator-client/package.json'));
// directories of public/ produced by this build (the other files of public/ are kept)
const GENERATED_DIRS = ['build/', 'vendor/', 'css/', 'font/', 'img/'];
module.exports = {
entry: './assets/demo.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'build/demo.js',
// removes the outdated files (ex : chunks of a previous version of the client)
clean: {
keep: (asset) => !GENERATED_DIRS.some((dir) => asset.startsWith(dir)),
},
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: path.join(clientDir, 'dist'),
to: 'vendor/validator-api-client',
// already minified by the client build (not processed again by terser)
info: { minimized: true },
},
{
from: path.join(clientDir, 'public/css'),
to: 'css',
},
{
from: path.join(clientDir, 'public/img'),
to: 'img',
},
{
from: path.join(clientDir, 'public/font'),
to: 'font',
// only woff2, woff, ttf and svg are referenced by style-carto.css
globOptions: {
ignore: ['**/*.eot', '**/*.otf', '**/selection.json'],
},
},
],
}),
],
// the copied files of the client are large (swagger-ui), demo.js is tiny
performance: {
hints: false,
},
};