Use tinypng.com upload/download achieve compress images
https://cloud.tencent.com/developer/article/1363596
- [X] Mini size
- [X] Cache
$ yarn add --dev make-img-tiny-loader file-loader@latest babel-loader@latest url-loader@latest
OR
$ npm i --save-dev make-img-tiny-loader file-loader@latest babel-loader@latest url-loader@latest
const path = require('path')
module.exports = {
mode: 'development',
entry: {
app: path.join(__dirname, './demo/index.js') // 打包内容入口
},
output: {
path: path.join(__dirname, './test/') // 出口
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name].[ext]',
publicPath: '/'
}
},
{
loader: path.resolve(__dirname, './node_modules/make-img-tiny-loader/dist/index.js')
}
]
}
]
},
optimization: {
minimize: false
}
}