mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2026-10-12 02:01:26 +00:00
Squashed commit of the following: commit 889c9051c7825c36961a92a36d20054bb4a77e46 Merge: d38b8a9845c44c4b26Author: Ildar Kamalov <[email protected]> Date: Mon Jul 27 12:59:55 2026 +0300 Merge branch 'master' into AGDNS-4277 commit d38b8a984458f15b17a7b096e298f3a4652d7a7b Author: Ildar Kamalov <[email protected]> Date: Mon Jul 27 12:03:14 2026 +0300 fix md lint commit 5bfc44e55269b44fbadaffa42844c7cbcfa751ec Author: Ildar Kamalov <[email protected]> Date: Mon Jul 27 11:55:57 2026 +0300 update changelog commit a1cdc0014ac5a69e56dce5a6bb80ad6a62b32bab Author: Ildar Kamalov <[email protected]> Date: Fri Jul 24 18:35:55 2026 +0300 fix protection_disabled_until commit b5bba05877dc887f07edfb20c640ea751beafb99 Author: Ildar Kamalov <[email protected]> Date: Fri Jul 24 17:01:46 2026 +0300 review fix commit fa365d0f4d203dd5a6d4607a766aed5bf779c045 Author: Ildar Kamalov <[email protected]> Date: Fri Jul 24 08:47:18 2026 +0000 Pull request 2730: AGDNS-4225 fix language change, add language selector to install Squashed commit of the following: commit9b4db74d65Merge:8371be2f0145a20744Author: Ildar Kamalov <[email protected]> Date: Fri Jul 24 11:39:45 2026 +0300 Merge branch 'AGDNS-4277' into AGDNS-4225 commit8371be2f08Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 16:58:47 2026 +0300 fix tests commit40cc9ccf42Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 16:22:13 2026 +0300 add some respect for login page commit6fa78d1946Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 15:58:28 2026 +0300 fix lang change on public pages commite8158d8a61Merge:a7c10ff297d88eb525Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 15:25:03 2026 +0300 Merge branch 'AGDNS-4277' into AGDNS-4225 commita7c10ff294Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 14:12:03 2026 +0300 fix lang labels commit9b59e83e39Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 14:05:01 2026 +0300 add fully translated zh cn commit817337ad81Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 13:53:27 2026 +0300 AGDNS-4225 fix lang import commitd3559e354bAuthor: Ildar Kamalov <[email protected]> Date: Thu Jul 23 12:21:24 2026 +0300 AGDNS-4225 fix language change, add language selector to install commit145a207442Author: Ildar Kamalov <[email protected]> Date: Fri Jul 24 11:36:33 2026 +0300 AGDNS-4277 review fix commit81a41ee4dcAuthor: Ildar Kamalov <[email protected]> Date: Fri Jul 24 10:12:06 2026 +0300 AGDNS-4277 review fix commit119f426bbeAuthor: Ildar Kamalov <[email protected]> Date: Thu Jul 23 18:00:56 2026 +0300 AGDNS-4277 fix get address entity commit31ae762860Merge:7d88eb525e8e328709Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 17:33:20 2026 +0300 Merge branch 'master' into AGDNS-4277 commit7d88eb5253Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 15:24:03 2026 +0300 missing translations commit3cc6179392Author: Ildar Kamalov <[email protected]> Date: Thu Jul 23 14:14:46 2026 +0300 fix commit7bd53b58e8Author: Ildar Kamalov <[email protected]> Date: Wed Jul 22 17:42:30 2026 +0300 safe search types commit77468b0b40Author: Ildar Kamalov <[email protected]> Date: Wed Jul 22 17:12:30 2026 +0300 revert commite73d826e7dMerge:bac2eaae8f078919e2Author: Ildar Kamalov <[email protected]> Date: Wed Jul 22 17:09:56 2026 +0300 Merge branch 'master' into AGDNS-4277 commitbac2eaae8bAuthor: Ildar Kamalov <[email protected]> Date: Wed Jul 22 17:09:14 2026 +0300 AGDNS-4277 commit1aee4f3025Merge:c79ff5454758376ee1Author: Ildar Kamalov <[email protected]> Date: Mon Jul 20 17:34:02 2026 +0300 Merge branch 'master' into AGDNS-4277 commitc79ff5454eAuthor: Ildar Kamalov <[email protected]> Date: Fri Jul 17 16:22:40 2026 +0300 AGDNS-4277 generate client api using openapi specs
186 lines
6.1 KiB
JavaScript
186 lines
6.1 KiB
JavaScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
import CopyPlugin from 'copy-webpack-plugin';
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
import { BUILD_ENVS } from './constants.js';
|
|
|
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
|
|
const RESOURCES_PATH = __dirname;
|
|
const ENTRY_MAIN = path.resolve(RESOURCES_PATH, 'src/index.tsx');
|
|
const ENTRY_INSTALL = path.resolve(RESOURCES_PATH, 'src/install/index.tsx');
|
|
const ENTRY_LOGIN = path.resolve(RESOURCES_PATH, 'src/login/index.tsx');
|
|
const ENTRY_FORGOT_PASSWORD = path.resolve(RESOURCES_PATH, 'src/forgot_password/index.tsx');
|
|
const HTML_PATH = path.resolve(RESOURCES_PATH, 'public/index.html');
|
|
const HTML_INSTALL_PATH = path.resolve(RESOURCES_PATH, 'public/install.html');
|
|
const HTML_LOGIN_PATH = path.resolve(RESOURCES_PATH, 'public/login.html');
|
|
const HTML_FORGOT_PASSWORD_PATH = path.resolve(RESOURCES_PATH, 'public/forgot_password.html');
|
|
const ASSETS_PATH = path.resolve(RESOURCES_PATH, 'public/assets');
|
|
|
|
const PUBLIC_PATH = path.resolve(RESOURCES_PATH, '../build/static');
|
|
const PUBLIC_ASSETS_PATH = path.resolve(PUBLIC_PATH, 'assets');
|
|
|
|
const BUILD_ENV = BUILD_ENVS[process.env.BUILD_ENV];
|
|
|
|
const isDev = BUILD_ENV === BUILD_ENVS.dev;
|
|
|
|
function getAliasesFromTsconfig(tsconfigPath, resourcesPath) {
|
|
const tsConfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
|
const aliases = {};
|
|
if (tsConfig.compilerOptions && tsConfig.compilerOptions.paths) {
|
|
Object.entries(tsConfig.compilerOptions.paths).forEach(([alias, targetArr]) => {
|
|
if (alias.endsWith('/*')) {
|
|
const aliasName = alias.replace('/*', '');
|
|
const target = targetArr[0].replace('/*', '');
|
|
aliases[aliasName] = path.resolve(resourcesPath, target);
|
|
} else {
|
|
aliases[alias] = path.resolve(resourcesPath, targetArr[0]);
|
|
}
|
|
});
|
|
}
|
|
return aliases;
|
|
}
|
|
|
|
const tsConfigPath = path.resolve(__dirname, './tsconfig.json');
|
|
const aliasesFromTsconfig = getAliasesFromTsconfig(tsConfigPath, RESOURCES_PATH);
|
|
|
|
const config = {
|
|
mode: BUILD_ENV,
|
|
target: 'web',
|
|
context: RESOURCES_PATH,
|
|
entry: {
|
|
main: ENTRY_MAIN,
|
|
install: ENTRY_INSTALL,
|
|
login: ENTRY_LOGIN,
|
|
forgot_password: ENTRY_FORGOT_PASSWORD,
|
|
},
|
|
output: {
|
|
path: PUBLIC_PATH,
|
|
filename: '[name].[chunkhash].js',
|
|
chunkFilename: 'assets/[name].[chunkhash].js',
|
|
},
|
|
resolve: {
|
|
modules: ['node_modules'],
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
alias: {
|
|
...aliasesFromTsconfig,
|
|
},
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ya?ml$/,
|
|
type: 'json',
|
|
use: 'yaml-loader',
|
|
},
|
|
{
|
|
test: /\.(svg|png|jpe?g|gif|webp|ico|woff2?)$/i,
|
|
type: 'asset/resource',
|
|
generator: {
|
|
filename: 'assets/[name].[contenthash][ext]',
|
|
},
|
|
},
|
|
{
|
|
test: /\.module\.pcss$/i,
|
|
use: [
|
|
{
|
|
loader: MiniCssExtractPlugin.loader,
|
|
},
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
modules: {
|
|
localIdentName: isDev
|
|
? '[name]__[local]--[hash:base64:5]'
|
|
: '[hash:base64]',
|
|
namedExport: false,
|
|
exportLocalsConvention: 'asIs',
|
|
},
|
|
esModule: true,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.p?css$/i,
|
|
exclude: /\.module\.pcss$/i,
|
|
use: [
|
|
{
|
|
loader: MiniCssExtractPlugin.loader,
|
|
},
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.tsx?$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new CleanWebpackPlugin({
|
|
root: PUBLIC_PATH,
|
|
verbose: false,
|
|
dry: false,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
cache: false,
|
|
chunks: ['main'],
|
|
template: HTML_PATH,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
cache: false,
|
|
chunks: ['install'],
|
|
filename: 'install.html',
|
|
template: HTML_INSTALL_PATH,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
cache: false,
|
|
chunks: ['login'],
|
|
filename: 'login.html',
|
|
template: HTML_LOGIN_PATH,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
cache: false,
|
|
chunks: ['forgot_password'],
|
|
filename: 'forgot_password.html',
|
|
template: HTML_FORGOT_PASSWORD_PATH,
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: isDev ? '[name].css' : '[name].[hash].css',
|
|
chunkFilename: isDev ? 'assets/[id].css' : 'assets/[id].[hash].css',
|
|
}),
|
|
new CopyPlugin({
|
|
patterns: [
|
|
{
|
|
from: ASSETS_PATH,
|
|
to: PUBLIC_ASSETS_PATH,
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
};
|
|
|
|
export default config;
|