2022-09-20 20:39:49 +03:00
|
|
|
import path from 'path';
|
|
|
|
import { Configuration } from 'webpack';
|
2022-10-04 19:00:37 +03:00
|
|
|
import CopyPlugin from 'copy-webpack-plugin';
|
2024-09-17 16:14:43 +03:00
|
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
|
import { version } from './package.json';
|
2022-04-21 17:52:54 +03:00
|
|
|
|
|
|
|
const config: Configuration = {
|
2022-09-20 20:39:49 +03:00
|
|
|
entry: './src/index.js',
|
2022-04-21 17:52:54 +03:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(ts|js)x?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
2022-09-20 20:39:49 +03:00
|
|
|
loader: 'babel-loader',
|
2022-04-21 17:52:54 +03:00
|
|
|
options: {
|
2022-09-20 20:39:49 +03:00
|
|
|
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
2022-04-21 17:52:54 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-12-02 14:31:21 +03:00
|
|
|
experiments: { asyncWebAssembly: true },
|
2022-04-21 17:52:54 +03:00
|
|
|
resolve: {
|
2022-09-20 20:39:49 +03:00
|
|
|
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
2022-09-28 16:49:07 +03:00
|
|
|
},
|
2022-09-28 15:08:16 +03:00
|
|
|
};
|
|
|
|
|
2024-09-17 16:14:43 +03:00
|
|
|
const configNode: Configuration = {
|
2022-09-28 15:08:16 +03:00
|
|
|
...config,
|
2022-04-21 17:52:54 +03:00
|
|
|
output: {
|
2022-09-20 20:39:49 +03:00
|
|
|
path: path.resolve(__dirname, 'static/frontend'),
|
2024-09-17 16:14:43 +03:00
|
|
|
filename: `main.v${version}.[contenthash].js`,
|
|
|
|
clean: true,
|
2024-09-17 17:35:43 +03:00
|
|
|
publicPath: './static/frontend/',
|
2022-04-21 17:52:54 +03:00
|
|
|
},
|
2024-09-17 16:14:43 +03:00
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
|
|
|
filename: path.resolve(__dirname, '../nodeapp/basic.html'),
|
|
|
|
robosatsSettings: 'selfhosted-basic',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/pro.html'),
|
|
|
|
filename: path.resolve(__dirname, '../nodeapp/pro.html'),
|
|
|
|
robosatsSettings: 'selfhosted-pro',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
|
|
|
filename: path.resolve(__dirname, '../web/basic.html'),
|
|
|
|
robosatsSettings: 'web-basic',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/pro.html'),
|
|
|
|
filename: path.resolve(__dirname, '../web/pro.html'),
|
|
|
|
robosatsSettings: 'web-pro',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static'),
|
|
|
|
to: path.resolve(__dirname, '../nodeapp/static'),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static'),
|
|
|
|
to: path.resolve(__dirname, '../web/static'),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
const configDesktop: Configuration = {
|
|
|
|
...config,
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, '../desktopApp/static/frontend'),
|
|
|
|
filename: `main.v${version}.[contenthash].js`,
|
|
|
|
clean: true,
|
2024-09-17 17:35:43 +03:00
|
|
|
publicPath: './static/frontend/',
|
2024-09-17 16:14:43 +03:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
|
|
|
filename: path.resolve(__dirname, '../desktopApp/index.html'),
|
|
|
|
robosatsSettings: 'desktop-basic',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static'),
|
|
|
|
to: path.resolve(__dirname, '../desktopApp/static'),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
2022-04-21 17:52:54 +03:00
|
|
|
};
|
|
|
|
|
2023-05-29 18:58:12 +03:00
|
|
|
const configMobile: Configuration = {
|
|
|
|
...config,
|
|
|
|
module: {
|
|
|
|
...config.module,
|
|
|
|
rules: [
|
|
|
|
...(config?.module?.rules || []),
|
|
|
|
{
|
|
|
|
test: path.resolve(__dirname, 'src/i18n/Web.js'),
|
|
|
|
loader: 'file-replace-loader',
|
|
|
|
options: {
|
|
|
|
condition: 'if-replacement-exists',
|
|
|
|
replacement: path.resolve(__dirname, 'src/i18n/Native.js'),
|
|
|
|
async: true,
|
|
|
|
},
|
|
|
|
},
|
2023-10-16 22:32:00 +03:00
|
|
|
{
|
|
|
|
test: path.resolve(__dirname, 'src/geo/Web.js'),
|
|
|
|
loader: 'file-replace-loader',
|
|
|
|
options: {
|
|
|
|
condition: 'if-replacement-exists',
|
|
|
|
replacement: path.resolve(__dirname, 'src/geo/Native.js'),
|
|
|
|
async: true,
|
|
|
|
},
|
|
|
|
},
|
2024-04-30 17:01:54 +03:00
|
|
|
{
|
|
|
|
test: path.resolve(__dirname, 'src/services/Roboidentities/Web.ts'),
|
|
|
|
loader: 'file-replace-loader',
|
|
|
|
options: {
|
|
|
|
condition: 'if-replacement-exists',
|
|
|
|
replacement: path.resolve(__dirname, 'src/services/Roboidentities/Native.ts'),
|
|
|
|
async: true,
|
|
|
|
},
|
|
|
|
},
|
2023-05-29 18:58:12 +03:00
|
|
|
{
|
|
|
|
test: path.resolve(__dirname, 'src/components/RobotAvatar/placeholder.json'),
|
|
|
|
loader: 'file-replace-loader',
|
|
|
|
options: {
|
|
|
|
condition: 'if-replacement-exists',
|
|
|
|
replacement: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'src/components/RobotAvatar/placeholder_highres.json',
|
|
|
|
),
|
|
|
|
async: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
plugins: [
|
2024-09-17 16:14:43 +03:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
|
|
|
filename: path.resolve(__dirname, '../mobile/html/Web.bundle/index.html'),
|
|
|
|
robosatsSettings: 'mobile-basic',
|
|
|
|
inject: 'body',
|
|
|
|
}),
|
2023-05-29 18:58:12 +03:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static/css'),
|
2024-09-17 16:14:43 +03:00
|
|
|
to: path.resolve(__dirname, '../mobile/html/Web.bundle/static'),
|
2024-04-30 23:02:54 +03:00
|
|
|
},
|
2023-05-29 18:58:12 +03:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
output: {
|
2024-09-17 16:14:43 +03:00
|
|
|
path: path.resolve(__dirname, '../mobile/html/Web.bundle/static/frontend'),
|
|
|
|
filename: `main.v${version}.[contenthash].js`,
|
|
|
|
clean: true,
|
2024-09-17 17:35:43 +03:00
|
|
|
publicPath: './static/frontend/',
|
2022-10-20 21:06:16 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-09-17 16:14:43 +03:00
|
|
|
export default [configNode, configDesktop, configMobile];
|