configs changes

master
Tudor Stanciu 2022-07-16 14:02:14 +03:00
parent d926f145cc
commit af084e84af
4 changed files with 17 additions and 22 deletions

View File

@ -1,4 +1,5 @@
const dev = {
NODE_ENV: "development",
REVERSE_PROXY_API_URL: "http://localhost:5050",
CHATBOT_API_URL: "http://localhost:5061",
REVERSE_PROXY_DOCS_URL: "https://toodle.ddns.net/hedgedoc/s/UkJ6S5NJz"
@ -12,4 +13,13 @@ const prod = {
REVERSE_PROXY_DOCS_URL: "https://toodle.ddns.net/hedgedoc/s/UkJ6S5NJz"
};
module.exports = { dev, prod };
const getConfig = env => {
const config = env === "prod" ? prod : dev;
let configs = {};
Object.keys(config).forEach(z => {
configs[`process.env.${z}`] = JSON.stringify(config[z]);
});
return configs;
};
module.exports = getConfig;

View File

@ -3,7 +3,7 @@ import api from "./api";
import { sendHttpRequest } from "../../redux/actions/httpActions";
export function loadReleaseNotes() {
return async function (dispatch, getState) {
return async function(dispatch, getState) {
try {
const notes = getState().releaseNotes;
if (notes && (notes.loading || notes.loaded)) return;

View File

@ -1,14 +1,10 @@
const webpack = require("webpack");
const path = require("path");
const config = require("./config");
const getConfig = require("./config");
const HtmlWebpackPlugin = require("html-webpack-plugin");
process.env.NODE_ENV = "development";
let configs = {};
Object.keys(config.dev).forEach(z => {
configs[`process.env.${z}`] = JSON.stringify(config.dev[z]);
});
const configs = getConfig("dev");
module.exports = {
mode: "development",

View File

@ -4,9 +4,11 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpackBundleAnalyzer = require("webpack-bundle-analyzer");
const CopyPlugin = require("copy-webpack-plugin");
const getConfig = require("./config");
process.env.NODE_ENV = "production";
process.env.PUBLIC_URL = "/reverse-proxy";
const configs = getConfig("prod");
module.exports = {
mode: "production",
@ -26,20 +28,7 @@ module.exports = {
filename: "[name].[contenthash].css"
}),
new webpack.DefinePlugin({
// This global makes sure React is built in prod mode.
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.PUBLIC_URL": JSON.stringify(process.env.PUBLIC_URL),
"process.env.REVERSE_PROXY_API_URL": JSON.stringify(
"https://toodle.ddns.net/reverse-proxy-api"
),
"process.env.CHATBOT_API_URL": JSON.stringify(
"https://toodle.ddns.net/chatbot-api"
),
"process.env.REVERSE_PROXY_DOCS_URL": JSON.stringify(
"https://toodle.ddns.net/docs/books/reverse-proxy"
)
}),
new webpack.DefinePlugin(configs),
new HtmlWebpackPlugin({
template: "src/index.html",
favicon: "src/favicon.ico",