2023-07-01 16:58:17 +00:00
|
|
|
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
|
|
|
|
|
|
|
const path = require("path");
|
2023-07-20 12:25:21 +00:00
|
|
|
const webpack = require("webpack");
|
2023-07-01 16:58:17 +00:00
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
|
|
const ESLintPlugin = require("eslint-webpack-plugin");
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
|
|
|
|
|
|
|
const isProduction = process.env.NODE_ENV == "production";
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
entry: {
|
|
|
|
main: "./src/index.tsx",
|
2023-07-20 12:25:21 +00:00
|
|
|
sw: {
|
|
|
|
import: "./src/service-worker.ts",
|
|
|
|
filename: "service-worker.js",
|
|
|
|
},
|
2023-07-01 16:58:17 +00:00
|
|
|
},
|
|
|
|
target: "browserslist",
|
2023-07-20 12:25:21 +00:00
|
|
|
mode: isProduction ? "production" : "development",
|
|
|
|
devtool: isProduction ? "source-map" : "cheap-module-source-map",
|
2023-07-01 16:58:17 +00:00
|
|
|
output: {
|
|
|
|
publicPath: "/",
|
|
|
|
path: path.resolve(__dirname, "build"),
|
|
|
|
filename: ({ runtime }) => {
|
|
|
|
if (runtime === "sw") {
|
|
|
|
return "[name].js";
|
|
|
|
}
|
|
|
|
return isProduction ? "[name].[chunkhash].js" : "[name].js";
|
|
|
|
},
|
|
|
|
clean: isProduction,
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
open: true,
|
|
|
|
host: "localhost",
|
|
|
|
historyApiFallback: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{ from: "public/manifest.json" },
|
|
|
|
{ from: "public/robots.txt" },
|
2023-07-04 17:34:41 +00:00
|
|
|
{ from: "public/icons.svg" },
|
2023-07-05 17:32:25 +00:00
|
|
|
{ from: "public/logo.png" },
|
2023-07-04 17:28:35 +00:00
|
|
|
{ from: "_headers" },
|
2023-07-01 16:58:17 +00:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: "public/index.html",
|
|
|
|
favicon: "public/favicon.ico",
|
|
|
|
excludeChunks: ["sw"],
|
|
|
|
}),
|
2023-07-20 12:25:21 +00:00
|
|
|
new ESLintPlugin({
|
|
|
|
extensions: ["js", "mjs", "jsx", "ts", "tsx"],
|
|
|
|
eslintPath: require.resolve("eslint"),
|
2023-08-01 09:47:49 +00:00
|
|
|
failOnError: true,
|
2023-07-20 12:25:21 +00:00
|
|
|
cache: true,
|
|
|
|
}),
|
2023-07-01 16:58:17 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: isProduction ? "[name].[chunkhash].css" : "[name].css",
|
|
|
|
}),
|
2023-07-20 12:25:21 +00:00
|
|
|
new webpack.IgnorePlugin({
|
|
|
|
resourceRegExp: /^\.\/locale$/,
|
|
|
|
contextRegExp: /moment$/,
|
|
|
|
})
|
2023-07-01 16:58:17 +00:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
2023-07-20 12:25:21 +00:00
|
|
|
{
|
|
|
|
enforce: "pre",
|
|
|
|
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
|
|
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
|
|
|
|
loader: require.resolve("source-map-loader"),
|
|
|
|
},
|
2023-07-01 16:58:17 +00:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/i,
|
2023-07-20 12:25:21 +00:00
|
|
|
exclude: /node_modules/,
|
2023-07-01 16:58:17 +00:00
|
|
|
use: [
|
|
|
|
{
|
2023-07-20 12:25:21 +00:00
|
|
|
loader: require.resolve("babel-loader"),
|
2023-07-01 16:58:17 +00:00
|
|
|
options: {
|
2023-07-20 12:25:21 +00:00
|
|
|
babelrc: false,
|
|
|
|
configFile: false,
|
|
|
|
presets: [
|
|
|
|
["@babel/preset-env", {
|
|
|
|
targets: "defaults"
|
|
|
|
}],
|
|
|
|
["@babel/preset-react", { runtime: "automatic" }],
|
|
|
|
"@babel/preset-typescript",
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
[
|
|
|
|
"formatjs",
|
|
|
|
{
|
|
|
|
idInterpolationPattern: "[sha512:contenthash:base64:6]",
|
|
|
|
ast: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
2023-07-01 16:58:17 +00:00
|
|
|
},
|
|
|
|
},
|
2023-08-01 09:47:49 +00:00
|
|
|
require.resolve("ts-loader")
|
2023-07-01 16:58:17 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
2023-07-20 12:25:21 +00:00
|
|
|
use: [MiniCssExtractPlugin.loader, require.resolve("css-loader")],
|
2023-07-01 16:58:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif|webp)$/i,
|
|
|
|
type: "asset",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
chunkIds: "deterministic",
|
|
|
|
minimize: isProduction,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
parse: {
|
|
|
|
ecma: 8,
|
|
|
|
},
|
|
|
|
compress: {
|
|
|
|
ecma: 5,
|
|
|
|
warnings: false,
|
|
|
|
comparisons: false,
|
|
|
|
inline: 2,
|
|
|
|
},
|
|
|
|
mangle: {
|
|
|
|
safari10: true,
|
|
|
|
},
|
|
|
|
keep_classnames: isProduction,
|
|
|
|
keep_fnames: isProduction,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
new CssMinimizerPlugin(),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
2023-07-20 12:25:21 +00:00
|
|
|
aliasFields: ["browser"],
|
|
|
|
extensions: ["...", ".tsx", ".ts", ".jsx", ".js"],
|
|
|
|
modules: ["...", __dirname, path.resolve(__dirname, "src")],
|
2023-07-20 11:33:00 +00:00
|
|
|
fallback: { "crypto": false }
|
2023-07-01 16:58:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-07-20 12:25:21 +00:00
|
|
|
module.exports = () => config;
|