-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
55 lines (52 loc) · 2.27 KB
/
craco.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
const path = require('path');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
webpack: {
alias: {
'@components': path.resolve(__dirname, 'src/components'),
'@ui': path.resolve(__dirname, 'src/UI'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@assets': path.resolve(__dirname, 'src/assets'),
'@layout': path.resolve(__dirname, 'src/layout'),
'@styles': path.resolve(__dirname, 'src/styles'),
'@store': path.resolve(__dirname, 'src/store'),
'@db': path.resolve(__dirname, 'src/db'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@fonts': path.resolve(__dirname, 'src/fonts'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@widgets': path.resolve(__dirname, 'src/widgets'),
'@contexts': path.resolve(__dirname, 'src/contexts'),
'@constants': path.resolve(__dirname, 'src/constants'),
},
configure: (webpackConfig, {env}) => {
webpackConfig.optimization.minimizer.push(
new ImageMinimizerPlugin({
generator: [
{
// You can apply generator using `?as=webp`, you can use any name and provide more options
preset: "webp",
implementation: ImageMinimizerPlugin.imageminGenerate,
options: {
// Please specify only one plugin here, multiple plugins will not work
plugins: ["imagemin-webp"],
},
},
],
}),
);
if (env === 'production') {
webpackConfig.plugins.push(
new CompressionPlugin({
test: /\.(js|css|html)$/,
filename: '[path][base].gz',
algorithm: 'gzip',
threshold: 10240,
minRatio: 0.8,
}),
);
}
return webpackConfig;
},
}
};