aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-04-13 11:16:03 -0400
committerBob Zeleznik <zzzman@gmail.com>2020-04-13 11:16:03 -0400
commited02920bd50e284e188376b142f494df4e330ac5 (patch)
treea18681a123dc50956c461023957224ce797b53e6 /webpack.config.js
parentb235c94614141752c98d24a395682a02297d9e6a (diff)
parentbf622aa5b5cd9d3256ee8e4f26245b9858cccfba (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js77
1 files changed, 49 insertions, 28 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 6a14dfcda..6265883fd 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -3,6 +3,36 @@ var webpack = require('webpack');
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
+const plugins = [
+ new CopyWebpackPlugin([{
+ from: "deploy",
+ to: path.join(__dirname, "build")
+ }]),
+ new ForkTsCheckerWebpackPlugin({
+ tslint: true,
+ useTypescriptIncrementalApi: true
+ }),
+ new webpack.optimize.OccurrenceOrderPlugin(),
+ 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;
+ }, {})));
+ }
+}
+
+transferEnvironmentVariables();
+
module.exports = {
mode: 'development',
entry: {
@@ -33,17 +63,18 @@ module.exports = {
extensions: ['.js', '.ts', '.tsx']
},
module: {
- rules: [
- {
+ rules: [{
test: [/\.tsx?$/],
- use: [
- { loader: 'ts-loader', options: { transpileOnly: true } }
- ]
+ use: [{
+ loader: 'ts-loader',
+ options: {
+ transpileOnly: true
+ }
+ }]
},
{
test: /\.scss|css$/,
- use: [
- {
+ use: [{
loader: "style-loader"
},
{
@@ -56,32 +87,22 @@ module.exports = {
},
{
test: /\.(jpg|png|pdf)$/,
- use: [
- {
- loader: 'file-loader'
- }
- ]
+ use: [{
+ loader: 'file-loader'
+ }]
},
{
test: /\.(png|jpg|gif)$/i,
- use: [
- {
- loader: 'url-loader',
- options: {
- limit: 8192
- }
+ use: [{
+ loader: 'url-loader',
+ options: {
+ limit: 8192
}
- ]
- }]
+ }]
+ }
+ ]
},
- plugins: [
- new CopyWebpackPlugin([{ from: "deploy", to: path.join(__dirname, "build") }]),
- new ForkTsCheckerWebpackPlugin({
- tslint: true, useTypescriptIncrementalApi: true
- }),
- new webpack.optimize.OccurrenceOrderPlugin(),
- new webpack.HotModuleReplacementPlugin(),
- ],
+ plugins,
devServer: {
compress: false,
host: "localhost",