mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
make env files work
This commit is contained in:
parent
3fb255721a
commit
b1d7649b17
@ -1,6 +1,17 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const Dotenv = require('dotenv-webpack');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
const readEnvFile = (pathToFile) => {
|
||||
const parsed = dotenv.config({ path: pathToFile }).parsed;
|
||||
|
||||
const env = {};
|
||||
for (const key in parsed) {
|
||||
env[key] = JSON.stringify(parsed[key]);
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: "./src/Index.tsx",
|
||||
@ -17,15 +28,15 @@ module.exports = {
|
||||
'react-native-sqlite-storage': 'react-native-sqlite-storage'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProvidePlugin({
|
||||
process: 'process/browser',
|
||||
}),
|
||||
// new webpack.DefinePlugin({
|
||||
// "process.env.hello": JSON.stringify(true),
|
||||
// }),
|
||||
// new Dotenv({ path: '../Common/.env' }),
|
||||
// new Dotenv({ path: '../CommonUI/.env'}),
|
||||
// new Dotenv({ path: './.env'})
|
||||
new webpack.DefinePlugin({
|
||||
'process': {
|
||||
'env': {
|
||||
...readEnvFile('../Common/.env'),
|
||||
...readEnvFile('../CommonUI/.env'),
|
||||
...readEnvFile('./.env')
|
||||
}
|
||||
}
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
|
@ -4,9 +4,8 @@ import Route from 'Common/Types/API/Route';
|
||||
import Version from 'Common/Types/Version';
|
||||
import URL from 'Common/Types/API/URL'
|
||||
|
||||
export const env: Function = (_key: string): string => {
|
||||
console.log(process.env['production']);
|
||||
return ''
|
||||
export const env: Function = (key: string): string => {
|
||||
return process.env[key] || '';
|
||||
};
|
||||
|
||||
export const API_PROTOCOL: Protocol = window.location.protocol.includes('https')
|
||||
|
Loading…
Reference in New Issue
Block a user