Skip to content

Commit 9210756

Browse files
authored
Merge pull request #8 from Reaper622/dev
Dev
2 parents 6cf52b0 + b0d6ec7 commit 9210756

File tree

21 files changed

+2134
-307
lines changed

21 files changed

+2134
-307
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ articles/
5858
```
5959
npm run build
6060
```
61-
61+
- 如要使用 HTTPS 服务则提前将SSL证书的 ssl.crt 与 ssl.key 存放在 server/ssl 目录中
6262
- 执行服务端运行指令
6363

6464
```
65-
npm run server
65+
npm run server // http
66+
npm run server:ssl // https
6667
```
6768

6869
- 访问 [localhost:4000](locahost:4000) 即可访问

config/webpack.common.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ const commonConfig = {
3333
use: ['happypack/loader?id=babel']
3434
},
3535
{
36-
test: /\.(png|svg|jpg|gif)$/,
37-
use: [{
36+
test: /\.(png|svg|jpg|gif|webp)$/,
37+
use: [
38+
{
3839
loader: 'url-loader',
3940
options: {
4041
// 30KB 以下大小的图片文件用base64编码来减少请求次数
41-
limit: 1024 - 30,
42+
limit: 1024 * 30,
4243
// 超出 30KB 的图片仍用 file-loader压缩
4344
fallback: 'file-loader'
4445
}
45-
}]
46+
}
47+
]
4648
},
4749
{
4850
test: /\.(woff|woff2|eot|ttf|otf)$/,

config/webpack.prod.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
66
const ModuleConcatenationPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
77
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
88
const CleanWebpackPlugin = require('clean-webpack-plugin');
9+
const ImageminPlugin = require('imagemin-webpack-plugin').default;
910

1011
const prodConfig = {
1112
mode: 'production',
@@ -65,7 +66,15 @@ const prodConfig = {
6566
}
6667
}
6768
}),
68-
new CleanWebpackPlugin()
69+
new CleanWebpackPlugin(),
70+
new ImageminPlugin({
71+
pngquant: {
72+
quality: '95-100'
73+
},
74+
jpegtran: {
75+
progressive: true
76+
}
77+
})
6978
],
7079
optimization: {
7180
// 代码分割

0 commit comments

Comments
 (0)