From 137c36a5e65cae30e08edd49d25a831b6d996944 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 24 Feb 2022 12:48:44 +0100 Subject: build: configure webpack to use dotenv --- .env.example | 6 ++++++ config/webpack/webpack.common.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.env.example b/.env.example index 5c9f355..7dba9e2 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,12 @@ # Type: string - Either 'production', 'development' or a custom environment. CURRENT_ENV='development' +######################### +# Ackee configuration # +######################### +ACKEE_DOMAIN="www.ackeeDomain.com" +ACKEE_SITE_ID="your-id-string" + ######################### # webpack configuration # ######################### diff --git a/config/webpack/webpack.common.js b/config/webpack/webpack.common.js index c2155e9..5396cb4 100644 --- a/config/webpack/webpack.common.js +++ b/config/webpack/webpack.common.js @@ -1,5 +1,7 @@ const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin'); +const { DefinePlugin } = require('webpack'); +const dotenv = require('dotenv').config(); const paths = require('./paths'); module.exports = { @@ -102,5 +104,17 @@ module.exports = { { from: paths.src.images, to: 'images', noErrorOnMissing: true }, ], }), + new DefinePlugin({ + 'process.env': JSON.stringify(dotenv.parsed), + 'process.env.ACKEE_DOMAIN': JSON.stringify(process.env.ACKEE_DOMAIN), + 'process.env.ACKEE_SITE_ID': JSON.stringify(process.env.ACKEE_SITE_ID), + }), ], + resolve: { + fallback: { + fs: false, + path: false, + os: false, + }, + }, }; -- cgit v1.2.3