72 lines
1.7 KiB
JavaScript
72 lines
1.7 KiB
JavaScript
const path = require('path');
|
|
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
|
|
const CompressionPlugin = require("compression-webpack-plugin");
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
|
|
|
|
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']
|
|
},
|
|
{
|
|
test:/\.(s*)css$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
'css-loader',
|
|
'sass-loader',
|
|
]
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new WebpackBuildNotifierPlugin({
|
|
title: "UDrone",
|
|
suppressSuccess: false, // don't spam success notifications
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: 'style.css',
|
|
})
|
|
],
|
|
optimization: {
|
|
minimize: isProduction,
|
|
minimizer: [
|
|
(compiler) => {
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
new TerserPlugin({
|
|
terserOptions: {
|
|
compress: {},
|
|
}
|
|
}).apply(compiler);
|
|
},
|
|
new CompressionPlugin({
|
|
test: /\.js(\?.*)?$/i,
|
|
}),
|
|
new CssMinimizerPlugin(),
|
|
],
|
|
},
|
|
resolve: {
|
|
extensions: ['*', '.js']
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, './dist'),
|
|
filename: 'bundle.js',
|
|
},
|
|
devServer: {
|
|
static: path.resolve(__dirname, './dist'),
|
|
},
|
|
}
|
|
};
|