2017-03-31 20:21:41 +02:00
|
|
|
const webpack = require('webpack');
|
2020-08-25 12:22:29 +02:00
|
|
|
const { merge } = require('webpack-merge');
|
2021-06-27 17:34:25 +02:00
|
|
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
2020-08-25 12:22:29 +02:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2020-12-03 10:15:21 +01:00
|
|
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
2020-08-25 12:22:29 +02:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-03-31 20:21:41 +02:00
|
|
|
|
2022-01-05 21:37:45 +01:00
|
|
|
const commonConfig = require('./common');
|
2017-03-31 20:21:41 +02:00
|
|
|
|
2020-11-11 09:48:04 +01:00
|
|
|
module.exports = merge(commonConfig, {
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
},
|
|
|
|
mode: 'production',
|
|
|
|
devtool: 'source-map',
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
parallel: true,
|
|
|
|
terserOptions: {
|
|
|
|
output: {
|
|
|
|
comments: false,
|
2020-08-25 12:22:29 +02:00
|
|
|
},
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
extractComments: false,
|
2017-06-20 07:14:04 +02:00
|
|
|
}),
|
2017-03-31 20:21:41 +02:00
|
|
|
],
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
2021-06-27 17:34:25 +02:00
|
|
|
new ESLintPlugin(),
|
2020-11-11 09:48:04 +01:00
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify('production'),
|
|
|
|
},
|
|
|
|
}),
|
2020-12-03 10:15:21 +01:00
|
|
|
new WebpackManifestPlugin({
|
2020-11-11 09:48:04 +01:00
|
|
|
fileName: 'manifest.json',
|
2020-12-08 09:34:17 +01:00
|
|
|
sort: (file1, file2) => file1.path.localeCompare(file2.path),
|
2020-11-11 09:48:04 +01:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: ['@babel/preset-env'],
|
|
|
|
},
|
2017-03-31 20:21:41 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
2017-03-31 20:21:41 +02:00
|
|
|
options: {
|
2020-11-11 09:48:04 +01:00
|
|
|
importLoaders: 1,
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
2017-03-31 20:21:41 +02:00
|
|
|
options: {
|
2020-11-11 09:48:04 +01:00
|
|
|
postcssOptions: {
|
|
|
|
plugins: ['autoprefixer'],
|
|
|
|
},
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
include: /node_modules/,
|
2022-01-05 15:56:13 +01:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
2022-01-05 21:37:45 +01:00
|
|
|
filename: 'img/[name][ext]',
|
2017-03-31 20:21:41 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png|gif|svg|ico)$/,
|
|
|
|
exclude: /node_modules/,
|
2022-01-05 15:56:13 +01:00
|
|
|
type: 'asset/resource',
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|ttf|woff|woff2)$/,
|
2022-01-05 15:56:13 +01:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
2022-01-05 21:37:45 +01:00
|
|
|
filename: 'fonts/[name][ext]',
|
2017-06-20 07:14:04 +02:00
|
|
|
},
|
2020-11-11 09:48:04 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|