mirror of
https://github.com/RoboSats/robosats.git
synced 2025-08-11 12:40:01 +00:00
Fix webview
This commit is contained in:
@ -34,216 +34,225 @@ const config: Configuration = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const configNode: Configuration = {
|
const configNode = (env: any, argv: { mode: string }): Configuration => {
|
||||||
...config,
|
return {
|
||||||
output: {
|
...config,
|
||||||
path: path.resolve(__dirname, 'static/frontend'),
|
output: {
|
||||||
filename: `main.v${version}.[contenthash].js`,
|
path: path.resolve(__dirname, 'static/frontend'),
|
||||||
clean: true,
|
filename:
|
||||||
publicPath: '/static/frontend/',
|
argv.mode === 'production' ? `main.v${version}.[contenthash].js` : `main.v${version}.js`,
|
||||||
},
|
clean: true,
|
||||||
plugins: [
|
publicPath: '/static/frontend/',
|
||||||
// Django
|
},
|
||||||
new HtmlWebpackPlugin({
|
plugins: [
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
// Django
|
||||||
templateParameters: {
|
new HtmlWebpackPlugin({
|
||||||
pro: false,
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
mobile: false,
|
templateParameters: {
|
||||||
},
|
pro: false,
|
||||||
filename: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
mobile: false,
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'web-basic',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
|
||||||
templateParameters: {
|
|
||||||
pro: true,
|
|
||||||
mobile: false,
|
|
||||||
},
|
|
||||||
filename: path.resolve(__dirname, 'templates/frontend/pro.html'),
|
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'web-pro',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
// Node App
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
|
||||||
templateParameters: {
|
|
||||||
pro: false,
|
|
||||||
mobile: false,
|
|
||||||
},
|
|
||||||
filename: path.resolve(__dirname, '../nodeapp/basic.html'),
|
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'selfhosted-basic',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
|
||||||
templateParameters: {
|
|
||||||
pro: true,
|
|
||||||
mobile: false,
|
|
||||||
},
|
|
||||||
filename: path.resolve(__dirname, '../nodeapp/pro.html'),
|
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'selfhosted-pro',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, 'static'),
|
|
||||||
to: path.resolve(__dirname, '../nodeapp/static'),
|
|
||||||
},
|
},
|
||||||
],
|
filename: path.resolve(__dirname, 'templates/frontend/basic.html'),
|
||||||
}),
|
inject: 'body',
|
||||||
// Desktop App
|
robosatsSettings: 'web-basic',
|
||||||
new HtmlWebpackPlugin({
|
basePath: '/',
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
}),
|
||||||
templateParameters: {
|
new HtmlWebpackPlugin({
|
||||||
pro: false,
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
mobile: false,
|
templateParameters: {
|
||||||
},
|
pro: true,
|
||||||
filename: path.resolve(__dirname, '../desktopApp/index.html'),
|
mobile: false,
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'desktop-basic',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, 'static'),
|
|
||||||
to: path.resolve(__dirname, '../desktopApp/static'),
|
|
||||||
},
|
},
|
||||||
],
|
filename: path.resolve(__dirname, 'templates/frontend/pro.html'),
|
||||||
}),
|
inject: 'body',
|
||||||
// Web App
|
robosatsSettings: 'web-pro',
|
||||||
new HtmlWebpackPlugin({
|
basePath: '/',
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
}),
|
||||||
templateParameters: {
|
// Node App
|
||||||
pro: false,
|
new HtmlWebpackPlugin({
|
||||||
mobile: false,
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
},
|
templateParameters: {
|
||||||
filename: path.resolve(__dirname, '../web/basic.html'),
|
pro: false,
|
||||||
inject: 'body',
|
mobile: false,
|
||||||
robosatsSettings: 'web-basic',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
|
||||||
templateParameters: {
|
|
||||||
pro: true,
|
|
||||||
mobile: false,
|
|
||||||
},
|
|
||||||
filename: path.resolve(__dirname, '../web/pro.html'),
|
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'web-pro',
|
|
||||||
basePath: '/',
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, 'static'),
|
|
||||||
to: path.resolve(__dirname, '../web/static'),
|
|
||||||
},
|
},
|
||||||
],
|
filename: path.resolve(__dirname, '../nodeapp/basic.html'),
|
||||||
}),
|
inject: 'body',
|
||||||
],
|
robosatsSettings: 'selfhosted-basic',
|
||||||
|
basePath: '/',
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
|
templateParameters: {
|
||||||
|
pro: true,
|
||||||
|
mobile: false,
|
||||||
|
},
|
||||||
|
filename: path.resolve(__dirname, '../nodeapp/pro.html'),
|
||||||
|
inject: 'body',
|
||||||
|
robosatsSettings: 'selfhosted-pro',
|
||||||
|
basePath: '/',
|
||||||
|
}),
|
||||||
|
new CopyWebpackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static'),
|
||||||
|
to: path.resolve(__dirname, '../nodeapp/static'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
// Desktop App
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
|
templateParameters: {
|
||||||
|
pro: false,
|
||||||
|
mobile: false,
|
||||||
|
},
|
||||||
|
filename: path.resolve(__dirname, '../desktopApp/index.html'),
|
||||||
|
inject: 'body',
|
||||||
|
robosatsSettings: 'desktop-basic',
|
||||||
|
basePath: '/',
|
||||||
|
}),
|
||||||
|
new CopyWebpackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static'),
|
||||||
|
to: path.resolve(__dirname, '../desktopApp/static'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
// Web App
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
|
templateParameters: {
|
||||||
|
pro: false,
|
||||||
|
mobile: false,
|
||||||
|
},
|
||||||
|
filename: path.resolve(__dirname, '../web/basic.html'),
|
||||||
|
inject: 'body',
|
||||||
|
robosatsSettings: 'web-basic',
|
||||||
|
basePath: '/',
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
|
templateParameters: {
|
||||||
|
pro: true,
|
||||||
|
mobile: false,
|
||||||
|
},
|
||||||
|
filename: path.resolve(__dirname, '../web/pro.html'),
|
||||||
|
inject: 'body',
|
||||||
|
robosatsSettings: 'web-pro',
|
||||||
|
basePath: '/',
|
||||||
|
}),
|
||||||
|
new CopyWebpackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static'),
|
||||||
|
to: path.resolve(__dirname, '../web/static'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const configAndroid: Configuration = {
|
const configAndroid = (env: any, argv: { mode: string }): Configuration => {
|
||||||
...config,
|
return {
|
||||||
module: {
|
...config,
|
||||||
...config.module,
|
module: {
|
||||||
rules: [
|
...config.module,
|
||||||
...(config?.module?.rules || []),
|
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/Mobile.js'),
|
|
||||||
async: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: path.resolve(__dirname, 'src/geo/Web.js'),
|
|
||||||
loader: 'file-replace-loader',
|
|
||||||
options: {
|
|
||||||
condition: 'if-replacement-exists',
|
|
||||||
replacement: path.resolve(__dirname, 'src/geo/Mobile.js'),
|
|
||||||
async: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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/Android.ts'),
|
|
||||||
async: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, '../android/app/src/main/assets/static/frontend'),
|
|
||||||
filename: `main.v${version}.[contenthash].js`,
|
|
||||||
clean: true,
|
|
||||||
publicPath: './static/frontend/',
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
|
||||||
templateParameters: {
|
|
||||||
pro: false,
|
|
||||||
mobile: true,
|
|
||||||
},
|
|
||||||
filename: path.resolve(__dirname, '../android/app/src/main/assets/index.html'),
|
|
||||||
inject: 'body',
|
|
||||||
robosatsSettings: 'mobile-basic',
|
|
||||||
basePath: 'file:///android_asset/',
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [
|
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, 'static/css'),
|
test: path.resolve(__dirname, 'src/i18n/Web.js'),
|
||||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/css'),
|
loader: 'file-replace-loader',
|
||||||
transform(content, path) {
|
options: {
|
||||||
if (path.endsWith('.css')) {
|
condition: 'if-replacement-exists',
|
||||||
let cssContent = content.toString();
|
replacement: path.resolve(__dirname, 'src/i18n/Mobile.js'),
|
||||||
cssContent = cssContent.replace(
|
async: true,
|
||||||
/url\(\/static\/css\/fonts\/roboto/g,
|
|
||||||
'url(file:///android_asset/static/css/fonts/roboto',
|
|
||||||
);
|
|
||||||
return Buffer.from(cssContent);
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, 'static/assets/sounds'),
|
test: path.resolve(__dirname, 'src/geo/Web.js'),
|
||||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/sounds'),
|
loader: 'file-replace-loader',
|
||||||
|
options: {
|
||||||
|
condition: 'if-replacement-exists',
|
||||||
|
replacement: path.resolve(__dirname, 'src/geo/Mobile.js'),
|
||||||
|
async: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, 'static/federation'),
|
test: path.resolve(__dirname, 'src/services/Roboidentities/Web.ts'),
|
||||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/federation'),
|
loader: 'file-replace-loader',
|
||||||
|
options: {
|
||||||
|
condition: 'if-replacement-exists',
|
||||||
|
replacement: path.resolve(__dirname, 'src/services/Roboidentities/Android.ts'),
|
||||||
|
async: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
output: {
|
||||||
|
path: path.resolve(__dirname, '../android/app/src/main/assets/static/frontend'),
|
||||||
|
filename:
|
||||||
|
argv.mode === 'production' ? `main.v${version}.[contenthash].js` : `main.v${version}.js`,
|
||||||
|
clean: true,
|
||||||
|
publicPath: './static/frontend/',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||||
|
templateParameters: {
|
||||||
|
pro: false,
|
||||||
|
mobile: true,
|
||||||
|
},
|
||||||
|
filename: path.resolve(__dirname, '../android/app/src/main/assets/index.html'),
|
||||||
|
inject: 'body',
|
||||||
|
robosatsSettings: 'mobile-basic',
|
||||||
|
basePath: 'file:///android_asset/',
|
||||||
|
}),
|
||||||
|
new CopyWebpackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static/css'),
|
||||||
|
to: path.resolve(__dirname, '../android/app/src/main/assets/static/css'),
|
||||||
|
transform(content, path) {
|
||||||
|
if (path.endsWith('.css')) {
|
||||||
|
let cssContent = content.toString();
|
||||||
|
cssContent = cssContent.replace(
|
||||||
|
/url\(\/static\/css\/fonts\/roboto/g,
|
||||||
|
'url(file:///android_asset/static/css/fonts/roboto',
|
||||||
|
);
|
||||||
|
return Buffer.from(cssContent);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static/assets/sounds'),
|
||||||
|
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/sounds'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, 'static/federation'),
|
||||||
|
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/federation'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default [configNode, configAndroid];
|
export default (env: any, argv: { mode: string }) => [
|
||||||
|
configNode(env, argv),
|
||||||
|
configAndroid(env, argv),
|
||||||
|
];
|
||||||
|
Reference in New Issue
Block a user