@@ -12,63 +12,65 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
1212const WebpackImageSizesPlugin = require ( './webpack-image-sizes-plugin' )
1313
1414module . exports = {
15- get : function ( mode ) {
16- const plugins = [
17- new CleanWebpackPlugin ( ) ,
18- new ESLintPlugin ( {
19- overrideConfigFile : path . resolve ( __dirname , '../.eslintrc' ) ,
20- context : path . resolve ( __dirname , '../src/js' ) ,
21- files : '**/*.js' ,
22- } ) ,
23- new SpriteLoaderPlugin ( {
24- plainSprite : true ,
25- } ) ,
26- new StyleLintPlugin ( {
27- configFile : path . resolve ( __dirname , '../.stylelintrc' ) ,
28- context : path . resolve ( __dirname , '../src/scss' ) ,
29- files : '**/*.scss' ,
30- } ) ,
31- new WebpackBar ( {
32- color : '#ffe600' ,
33- } ) ,
34- new DependencyExtractionWebpackPlugin ( ) ,
35- new WebpackImageSizesPlugin ( {
36- confImgPath : 'assets/conf-img' , // Path to the conf-img folder
37- sizesSubdir : 'sizes' , // Subdirectory containing the sizes JSON files
38- tplSubdir : 'tpl' , // Subdirectory containing TPL templates
39- outputImageLocations : 'image-locations.json' , // Output locations file name
40- outputImageSizes : 'image-sizes.json' , // Output sizes file name
41- generateDefaultImages : true , // Generate default images
42- defaultImageSource : 'src/img/static/default.jpg' , // Source image for generation
43- defaultImagesOutputDir : 'dist/images' , // Default images output directory
44- defaultImageFormat : 'jpg' , // Generated image format (jpg, png, webp, avif)
45- silence : true , // Suppress console output
46- } ) ,
47- ]
15+ get : function ( mode ) {
16+ const plugins = [
17+ new CleanWebpackPlugin ( {
18+ cleanOnceBeforeBuildPatterns : [ '**/*' , '!images' , '!images/**' ] ,
19+ } ) ,
20+ new ESLintPlugin ( {
21+ overrideConfigFile : path . resolve ( __dirname , '../.eslintrc' ) ,
22+ context : path . resolve ( __dirname , '../src/js' ) ,
23+ files : '**/*.js' ,
24+ } ) ,
25+ new SpriteLoaderPlugin ( {
26+ plainSprite : true ,
27+ } ) ,
28+ new StyleLintPlugin ( {
29+ configFile : path . resolve ( __dirname , '../.stylelintrc' ) ,
30+ context : path . resolve ( __dirname , '../src/scss' ) ,
31+ files : '**/*.scss' ,
32+ } ) ,
33+ new WebpackBar ( {
34+ color : '#ffe600' ,
35+ } ) ,
36+ new DependencyExtractionWebpackPlugin ( ) ,
37+ new WebpackImageSizesPlugin ( {
38+ confImgPath : 'assets/conf-img' , // Path to the conf-img folder
39+ sizesSubdir : 'sizes' , // Subdirectory containing the sizes JSON files
40+ tplSubdir : 'tpl' , // Subdirectory containing TPL templates
41+ outputImageLocations : 'image-locations.json' , // Output locations file name
42+ outputImageSizes : 'image-sizes.json' , // Output sizes file name
43+ generateDefaultImages : true , // Generate default images
44+ defaultImageSource : 'src/img/static/default.jpg' , // Source image for generation
45+ defaultImagesOutputDir : 'dist/images' , // Default images output directory
46+ defaultImageFormat : 'jpg' , // Generated image format (jpg, png, webp, avif)
47+ silence : true , // Suppress console output
48+ } ) ,
49+ ]
4850
49- if ( mode === 'production' ) {
50- plugins . push (
51- new BundleAnalyzerPlugin ( {
52- analyzerMode : 'json' ,
53- generateStatsFile : true ,
54- } )
55- )
56- plugins . push (
57- new WebpackManifestPlugin ( {
58- fileName : 'assets.json' ,
59- } ) ,
60- new MiniCssExtractPlugin ( {
61- filename : '[name].[contenthash:8].min.css' ,
62- } )
63- )
64- } else {
65- plugins . push (
66- new MiniCssExtractPlugin ( {
67- filename : '[name].css' ,
68- } )
69- )
70- }
51+ if ( mode === 'production' ) {
52+ plugins . push (
53+ new BundleAnalyzerPlugin ( {
54+ analyzerMode : 'json' ,
55+ generateStatsFile : true ,
56+ } )
57+ )
58+ plugins . push (
59+ new WebpackManifestPlugin ( {
60+ fileName : 'assets.json' ,
61+ } ) ,
62+ new MiniCssExtractPlugin ( {
63+ filename : '[name].[contenthash:8].min.css' ,
64+ } )
65+ )
66+ } else {
67+ plugins . push (
68+ new MiniCssExtractPlugin ( {
69+ filename : '[name].css' ,
70+ } )
71+ )
72+ }
7173
72- return plugins
73- } ,
74+ return plugins
75+ } ,
7476}
0 commit comments