oneuptime/Dashboard/webpack.config.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-05-22 08:49:16 +00:00
const path = require("path");
const webpack = require("webpack");
2022-05-24 13:22:56 +00:00
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;
}
2022-05-22 08:49:16 +00:00
module.exports = {
entry: "./src/Index.tsx",
mode: "development",
output: {
filename: "bundle.js",
2022-06-13 12:01:37 +00:00
path: path.resolve(__dirname, "dist"),
2022-07-05 13:40:17 +00:00
publicPath: "/assets/",
2022-05-22 08:49:16 +00:00
},
resolve: {
2022-07-05 13:40:17 +00:00
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.css', '.scss'],
2022-06-27 13:19:59 +00:00
alias: {
react: path.resolve('./node_modules/react'),
}
2022-05-22 08:49:16 +00:00
},
externals: {
'react-native-sqlite-storage': 'react-native-sqlite-storage'
},
2022-05-24 13:22:56 +00:00
plugins: [
new webpack.DefinePlugin({
'process': {
'env': {
...readEnvFile('../Common/.env'),
...readEnvFile('../CommonUI/.env'),
...readEnvFile('./.env')
}
}
2022-06-27 13:19:59 +00:00
}),
2022-05-24 13:22:56 +00:00
],
2022-05-22 08:49:16 +00:00
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader'
},
{
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', "sass-loader"]
},
{
2022-06-27 19:46:08 +00:00
test: /\.(jpe?g|png|gif|svg)$/i,
2022-07-05 13:40:17 +00:00
loader: 'file-loader'
2022-05-22 08:49:16 +00:00
}
],
},
devServer: {
historyApiFallback: true,
2022-07-05 13:40:17 +00:00
devMiddleware: {
writeToDisk: true,
},
2022-05-22 08:49:16 +00:00
},
2022-06-29 20:51:49 +00:00
devtool: 'eval-source-map',
2022-05-22 08:49:16 +00:00
}