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