Skip to content

Commit

Permalink
Fixed dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Jun 28, 2022
1 parent ba1916d commit e323760
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
32 changes: 25 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"danger": "^11.0.7",
"dotenv": "^16.0.1",
"dotenv-webpack": "^7.1.0",
"esbuild-jest": "^0.5.0",
"esbuild-loader": "^2.19.0",
Expand Down
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const { merge } = require('webpack-merge');

const commonConfig = require('./config/webpack.common.js');
require('dotenv').config();

/**
* getAddons is a function that returns valid addon modules
Expand All @@ -15,7 +17,10 @@ const getAddons = (addons = '') =>
.map((name) => require(`./config/addons/webpack.${name}.js`));

module.exports = ({ env, addon }) => {
const envConfig = require(`./config/webpack.${env || 'production'}.js`);
const targetEnv = env || 'production';

require('dotenv').config({ path: path.resolve(process.cwd(), `.env.${targetEnv}`) });
const envConfig = require(`./config/webpack.${targetEnv}.js`);

return merge(commonConfig, envConfig, ...getAddons(addon));
};

0 comments on commit e323760

Please sign in to comment.