aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-05-15 19:10:07 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-05-15 19:10:07 -0700
commit253d5efbbafe4a44c350fef7dda6d553a70a94c9 (patch)
treeb43a55e1efddc86e25df4bb7d90a99f3c7b52a17 /webpack.config.js
parent36c01920e3874e1484222a7012745b581405f67d (diff)
parent08b6bf8b51ab631c8cfe9c3e12bfb0ae2dd7b4c7 (diff)
merge with master
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'
]