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 path = require("path");
|
||||||
const webpack = require("webpack");
|
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 = {
|
module.exports = {
|
||||||
entry: "./src/Index.tsx",
|
entry: "./src/Index.tsx",
|
||||||
@ -17,15 +28,15 @@ module.exports = {
|
|||||||
'react-native-sqlite-storage': 'react-native-sqlite-storage'
|
'react-native-sqlite-storage': 'react-native-sqlite-storage'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ProvidePlugin({
|
new webpack.DefinePlugin({
|
||||||
process: 'process/browser',
|
'process': {
|
||||||
}),
|
'env': {
|
||||||
// new webpack.DefinePlugin({
|
...readEnvFile('../Common/.env'),
|
||||||
// "process.env.hello": JSON.stringify(true),
|
...readEnvFile('../CommonUI/.env'),
|
||||||
// }),
|
...readEnvFile('./.env')
|
||||||
// new Dotenv({ path: '../Common/.env' }),
|
}
|
||||||
// new Dotenv({ path: '../CommonUI/.env'}),
|
}
|
||||||
// new Dotenv({ path: './.env'})
|
}),
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -4,9 +4,8 @@ import Route from 'Common/Types/API/Route';
|
|||||||
import Version from 'Common/Types/Version';
|
import Version from 'Common/Types/Version';
|
||||||
import URL from 'Common/Types/API/URL'
|
import URL from 'Common/Types/API/URL'
|
||||||
|
|
||||||
export const env: Function = (_key: string): string => {
|
export const env: Function = (key: string): string => {
|
||||||
console.log(process.env['production']);
|
return process.env[key] || '';
|
||||||
return ''
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const API_PROTOCOL: Protocol = window.location.protocol.includes('https')
|
export const API_PROTOCOL: Protocol = window.location.protocol.includes('https')
|
||||||
|
Loading…
Reference in New Issue
Block a user