udrone/webpack.config.js

72 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-08-18 22:20:07 +03:00
const path = require('path');
2022-09-22 23:18:43 +03:00
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const CompressionPlugin = require("compression-webpack-plugin");
2022-09-23 13:22:14 +03:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
2022-08-18 22:20:07 +03:00
2022-09-22 23:18:43 +03:00
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
performance: {
maxAssetSize: 5000000,
maxEntrypointSize: 5000000,
},
entry: path.resolve(__dirname, './src/index.js'),
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: ['babel-loader']
2022-09-23 13:22:14 +03:00
},
{
test:/\.(s*)css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
]
}
2022-09-22 23:18:43 +03:00
]
},
plugins: [
new WebpackBuildNotifierPlugin({
title: "UDrone",
suppressSuccess: false, // don't spam success notifications
}),
2022-09-23 13:22:14 +03:00
new MiniCssExtractPlugin({
filename: 'style.css',
})
2022-09-22 23:18:43 +03:00
],
optimization: {
minimize: isProduction,
minimizer: [
(compiler) => {
const TerserPlugin = require('terser-webpack-plugin');
new TerserPlugin({
terserOptions: {
compress: {},
}
}).apply(compiler);
},
new CompressionPlugin({
test: /\.js(\?.*)?$/i,
2022-09-23 13:22:14 +03:00
}),
new CssMinimizerPlugin(),
2022-09-22 23:18:43 +03:00
],
},
resolve: {
extensions: ['*', '.js']
},
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
},
devServer: {
static: path.resolve(__dirname, './dist'),
},
}
2022-08-18 22:20:07 +03:00
};