50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
|
|
module.exports = {
|
|
entry: './src/main.js',
|
|
output: {
|
|
filename: "bundle.js",
|
|
clean: true,
|
|
path: path.resolve(__dirname, "dist"),
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/i,
|
|
use: ['style-loader', 'css-loader'],
|
|
},
|
|
{
|
|
test: /\.(png|gif|jpe?g|webp|svg)$/i,
|
|
type: "asset",
|
|
// use: ['file-loader'],
|
|
},
|
|
{
|
|
test: /\.(woff|woff2|otf|ttf|eot)$/i,
|
|
type: "asset/resource",
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: "./src/template.html",
|
|
})
|
|
],
|
|
optimization: {
|
|
minimizer: [
|
|
new ImageMinimizerPlugin({
|
|
minimizer: {
|
|
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
options: {
|
|
plugins: [
|
|
// ["gifsicle", { interlaced: true }],
|
|
["jpegtran", { progressive: true }],
|
|
// ["optipng", { optimizationLevel: 5 }],
|
|
],
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
},
|
|
} |