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';
|
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
|
|
|
};
|
|
|
|
|
|
|
|
const configWeb: Configuration = {
|
|
|
|
...config,
|
2022-04-21 17:52:54 +03:00
|
|
|
output: {
|
2022-09-20 20:39:49 +03:00
|
|
|
path: path.resolve(__dirname, 'static/frontend'),
|
2022-10-22 17:32:33 +03:00
|
|
|
filename: 'main.js',
|
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: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static/css'),
|
|
|
|
to: path.resolve(__dirname, '../mobile/html/Web.bundle/css'),
|
|
|
|
},
|
2023-05-29 19:01:57 +03:00
|
|
|
{
|
|
|
|
from: path.resolve(__dirname, 'static/assets/sounds'),
|
|
|
|
to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/sounds'),
|
|
|
|
},
|
2023-05-29 18:58:12 +03:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, '../mobile/html/Web.bundle/js'),
|
|
|
|
filename: 'main.js',
|
2022-10-20 21:06:16 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-04-03 08:55:42 +03:00
|
|
|
export default [configWeb, configMobile];
|