Skip to content

Commit 68f0767

Browse files
committed
Only minify Images on live build
1 parent c445ac3 commit 68f0767

File tree

3 files changed

+55
-61
lines changed

3 files changed

+55
-61
lines changed

Resources/Build/webpack.common.js

+17-58
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ const path = require('path');
22
const webpack = require('webpack');
33
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
44
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
5-
const CleanWebpackPlugin = require('clean-webpack-plugin');
65
const StyleLintPlugin = require('stylelint-webpack-plugin');
76
const WebpackBar = require('webpackbar');
87
const CopyPlugin = require('copy-webpack-plugin');
98
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
10-
const ImageminPlugin = require('imagemin-webpack-plugin').default;
119

1210
module.exports = {
1311
stats: 'none',
@@ -26,7 +24,12 @@ module.exports = {
2624
exclude: /node_modules/,
2725
loader: "eslint-loader",
2826
options: {
29-
configFile: '.eslintrc.json'
27+
cache: false,
28+
configFile: '.eslintrc.json',
29+
emitError: true,
30+
emitWarning: true,
31+
failOnError: false,
32+
failOnWarning: false,
3033
}
3134
},
3235
{
@@ -92,39 +95,13 @@ module.exports = {
9295
name: '[path][name].[ext]',
9396
outputPath: 'Images/'
9497
}
95-
},
96-
{
97-
loader: 'image-webpack-loader',
98-
options: {
99-
cacheFolder: path.resolve('./cache'),
100-
mozjpeg: {
101-
progressive: true,
102-
quality: 65
103-
},
104-
// optipng.enabled: false will disable optipng
105-
optipng: {
106-
enabled: false,
107-
},
108-
pngquant: {
109-
quality: [0.65, 0.90],
110-
speed: 4
111-
},
112-
gifsicle: {
113-
interlaced: false,
114-
},
115-
// the webp option will enable WEBP
116-
webp: {
117-
quality: 75
118-
}
119-
}
12098
}
12199
]
122100
}
123101
]
124102
},
125103
plugins: [
126104
new webpack.ProgressPlugin(),
127-
// new CleanWebpackPlugin(),
128105
new WebpackBar({
129106
clear: false,
130107
profile: true,
@@ -136,42 +113,24 @@ module.exports = {
136113
sourceMap: true
137114
}),
138115
new CopyPlugin(
139-
[{from: 'Assets/Images/Misc', to: 'Images/Misc'}],
140-
{copyUnmodified: true}
116+
[{
117+
from: 'Assets/Images/Misc', to: 'Images/Misc',
118+
cache: true,
119+
}]
141120
),
142121
new CopyPlugin([
143-
{from: 'Assets/JavaScripts/static', to: 'JavaScripts'},
144-
{from: 'Assets/CKEditor', to: 'CKEditor'}
122+
{from: 'Assets/JavaScripts/static', to: 'JavaScripts', cache: true},
123+
{from: 'Assets/CKEditor', to: 'CKEditor', cache: true},
145124
]),
146-
new ImageminPlugin({
147-
test: /\.(jpe?g|png|gif|svg)$/i,
148-
options: {
149-
cacheFolder: path.resolve('./cache'),
150-
mozjpeg: {
151-
progressive: true,
152-
quality: 65
153-
},
154-
// optipng.enabled: false will disable optipng
155-
optipng: {
156-
enabled: false,
157-
},
158-
pngquant: {
159-
quality: [0.65, 0.90],
160-
speed: 4
161-
},
162-
gifsicle: {
163-
interlaced: false,
164-
},
165-
// the webp option will enable WEBP
166-
webp: {
167-
quality: 75
168-
}
169-
}
170-
}),
171125
new StyleLintPlugin({
172126
configFile: ".stylelintrc.json",
173127
syntax: 'scss',
174128
files: '**/*.scss',
129+
quiet: false,
130+
emitError: true,
131+
emitWarning: true,
132+
failOnError: false,
133+
failOnWarning: false,
175134
}),
176135
],
177136
};

Resources/Build/webpack.dev.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
const merge = require('webpack-merge');
2-
const StyleLintPlugin = require('stylelint-webpack-plugin');
32
const baseConfig = require('./webpack.common.js');
3+
const ImageminPlugin = require('imagemin-webpack-plugin').default;
44

55
const developConfig = {
66
mode: 'development',
7-
devtool: "source-map"
7+
devtool: "source-map",
8+
plugins: [
9+
new ImageminPlugin({
10+
disable: true
11+
}),
12+
]
813
};
914

1015
module.exports = merge.smart(baseConfig, developConfig);

Resources/Build/webpack.prod.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
const merge = require('webpack-merge');
22
const baseConfig = require('./webpack.common.js');
3+
const ImageminPlugin = require('imagemin-webpack-plugin').default;
34

45
const productionConfig = {
56
mode: 'production',
6-
performance: {hints: false}
7+
performance: {hints: false},
8+
plugins: [
9+
new ImageminPlugin({
10+
test: /\.(jpe?g|png|gif|svg)$/i,
11+
mozjpeg: {
12+
cacheFolder: '.cache',
13+
progressive: true,
14+
quality: '65-75',
15+
},
16+
// optipng.enabled: false will disable optipng
17+
optipng: {
18+
cacheFolder: '.cache',
19+
enabled: false,
20+
},
21+
pngquant: {
22+
cacheFolder: '.cache',
23+
quality: '65-75',
24+
speed: 4
25+
},
26+
gifsicle: {
27+
cacheFolder: '.cache',
28+
interlaced: false,
29+
},
30+
// the webp option will enable WEBP
31+
webp: {
32+
cacheFolder: '.cache',
33+
quality: '65-75',
34+
}
35+
}),
36+
]
737
};
838

939
module.exports = merge.smart(baseConfig, productionConfig);

0 commit comments

Comments
 (0)