2022-09-28 12:29:53 +00:00
|
|
|
const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
|
|
|
const dotenv = require('dotenv');
|
2022-12-07 14:13:33 +00:00
|
|
|
const express = require('express');
|
2022-09-28 12:29:53 +00:00
|
|
|
|
|
|
|
const readEnvFile = (pathToFile) => {
|
2022-12-07 14:13:33 +00:00
|
|
|
|
2022-09-28 12:29:53 +00:00
|
|
|
const parsed = dotenv.config({ path: pathToFile }).parsed;
|
|
|
|
|
|
|
|
const env = {};
|
2022-12-07 14:13:33 +00:00
|
|
|
|
2022-09-28 12:29:53 +00:00
|
|
|
for (const key in parsed) {
|
|
|
|
env[key] = JSON.stringify(parsed[key]);
|
|
|
|
}
|
|
|
|
|
2022-12-07 14:13:33 +00:00
|
|
|
|
2022-09-28 12:29:53 +00:00
|
|
|
return env;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: "./src/Index.tsx",
|
|
|
|
mode: "development",
|
|
|
|
output: {
|
|
|
|
filename: "bundle.js",
|
2022-12-07 14:13:33 +00:00
|
|
|
path: path.resolve(__dirname, "public", "dist"),
|
|
|
|
publicPath: "/status-page/dist/",
|
2022-09-28 12:29:53 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.css', '.scss'],
|
|
|
|
alias: {
|
|
|
|
react: path.resolve('./node_modules/react'),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
'react-native-sqlite-storage': 'react-native-sqlite-storage'
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process': {
|
|
|
|
'env': {
|
|
|
|
...readEnvFile('../Common/.env'),
|
|
|
|
...readEnvFile('../CommonUI/.env'),
|
|
|
|
...readEnvFile('./.env')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(ts|tsx)$/,
|
|
|
|
use: 'ts-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: ['style-loader', 'css-loader', "sass-loader"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: ['style-loader', 'css-loader']
|
|
|
|
},
|
|
|
|
{
|
2022-12-07 14:13:33 +00:00
|
|
|
test: /\.(jpe?g|png|gif|svg)$/i,
|
2022-09-28 12:29:53 +00:00
|
|
|
loader: 'file-loader'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
historyApiFallback: true,
|
|
|
|
devMiddleware: {
|
|
|
|
writeToDisk: true,
|
|
|
|
},
|
2022-12-07 14:13:33 +00:00
|
|
|
allowedHosts: "all",
|
|
|
|
setupMiddlewares: (middlewares, devServer) => {
|
|
|
|
devServer.app.use('/status-page/assets', express.static(path.resolve(__dirname, 'public', 'assets')));
|
|
|
|
return middlewares;
|
|
|
|
}
|
2022-09-28 12:29:53 +00:00
|
|
|
},
|
|
|
|
devtool: 'eval-source-map',
|
|
|
|
}
|