-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathimageLoadersList.js
64 lines (56 loc) · 1.61 KB
/
imageLoadersList.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
const JPEG_QUALITY = 93;
const fileLoader = {
loader : 'file-loader',
options : { name: '[name].[ext]' },
};
const imgLoader = {
loader : '@regru/img-loader',
options : {
enabled : false, // ivan.sobolev у меня не получается наладить
// Module build failed: Error: spawn /www/srs/node_modules/mozjpeg/vendor/cjpeg ENOENT
mozjpeg : {
quality : JPEG_QUALITY,
progressive : true,
arithmetic : false,
},
optipng : false,
},
};
function getLoadersList( withOptimizers, env, context ) {
const isProductionBuild = 2;
const isDevBuild = 0;
const isDevServer = 1;
switch ( env ) {
case isProductionBuild:
fileLoader.options.name = '[name].[hash].[ext]';
if ( withOptimizers ) {
return [
fileLoader,
imgLoader,
];
}
return [ fileLoader ];
case isDevBuild:
default:
if ( withOptimizers ) {
return [
fileLoader,
imgLoader,
];
}
return [
fileLoader,
];
case isDevServer:
return [
{
loader : '@regru/img-dev-loader',
options : {
context : context,
prefix : process.env.IMG_DEV_LOADER_URL_PREFIX || '',
},
},
];
}
}
module.exports = getLoadersList;