aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js96
1 files changed, 43 insertions, 53 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 6265883fd..bd1d3b5a9 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -16,19 +16,21 @@ const plugins = [
new webpack.HotModuleReplacementPlugin(),
];
-const dotenv = require('dotenv');
-
function transferEnvironmentVariables() {
const prefix = "_CLIENT_";
- const env = dotenv.config().parsed;
- if (env) {
- plugins.push(new webpack.DefinePlugin(Object.keys(env).reduce((mapping, envKey) => {
- if (envKey.startsWith(prefix)) {
- mapping[`process.env.${envKey.replace(prefix, "")}`] = JSON.stringify(env[envKey]);
- }
- return mapping;
- }, {})));
+ const {
+ parsed
+ } = require('dotenv').config();
+ if (!parsed) {
+ return;
}
+ const resolvedClientSide = Object.keys(parsed).reduce((mapping, envKey) => {
+ if (envKey.startsWith(prefix)) {
+ mapping[`process.env.${envKey.replace(prefix, "")}`] = JSON.stringify(parsed[envKey]);
+ }
+ return mapping;
+ }, {});
+ plugins.push(new webpack.DefinePlugin(resolvedClientSide));
}
transferEnvironmentVariables();
@@ -64,57 +66,45 @@ module.exports = {
},
module: {
rules: [{
- test: [/\.tsx?$/],
- use: [{
- loader: 'ts-loader',
- options: {
- transpileOnly: true
- }
- }]
- },
- {
- test: /\.scss|css$/,
- use: [{
- loader: "style-loader"
- },
- {
- loader: "css-loader"
- },
- {
- loader: "sass-loader"
- }
- ]
+ test: [/\.tsx?$/],
+ use: [{
+ loader: 'ts-loader',
+ options: {
+ transpileOnly: true
+ }
+ }]
+ },
+ {
+ test: /\.scss|css$/,
+ use: [{
+ loader: "style-loader"
},
{
- test: /\.(jpg|png|pdf)$/,
- use: [{
- loader: 'file-loader'
- }]
+ loader: "css-loader"
},
{
- test: /\.(png|jpg|gif)$/i,
- use: [{
- loader: 'url-loader',
- options: {
- limit: 8192
- }
- }]
+ loader: "sass-loader"
}
+ ]
+ },
+ {
+ test: /\.(jpg|png|pdf)$/,
+ use: [{
+ loader: 'file-loader'
+ }]
+ },
+ {
+ test: /\.(png|jpg|gif)$/i,
+ use: [{
+ loader: 'url-loader',
+ options: {
+ limit: 8192
+ }
+ }]
+ }
]
},
plugins,
- devServer: {
- compress: false,
- host: "localhost",
- contentBase: path.join(__dirname, 'deploy'),
- port: 4321,
- hot: true,
- https: false,
- overlay: {
- warnings: true,
- errors: true
- }
- },
externals: [
'child_process'
]