Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 6793e11

Browse files
committed
chore(shared): fix DOTENV_CONFIG_PATH resolution in webpack config (#359)
1 parent d5d575f commit 6793e11

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

commitlint.config.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ module.exports = {
77
'scope-enum': [
88
2,
99
'always',
10-
['workspace', 'guardoni', 'ycai', 'taboule', 'tktrex', 'yttrex'],
10+
[
11+
'workspace',
12+
'shared',
13+
'taboule',
14+
'backend',
15+
'guardoni',
16+
'ycai',
17+
'tktrex',
18+
],
1119
],
1220
'type-enum': [
1321
2,

packages/shared/src/webpack/config.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
2+
import D from 'debug';
23
import dotenv from 'dotenv';
34
import { pipe } from 'fp-ts/lib/function';
45
import * as R from 'fp-ts/lib/Record';
@@ -52,19 +53,28 @@ interface GetConfigParams<E extends t.Props> {
5253
const getConfig = <E extends t.Props>(
5354
opts: GetConfigParams<E>
5455
): WebpackConfig => {
55-
const mode =
56-
process.env.NODE_ENV === 'production' ? 'production' : 'development';
57-
5856
const DOTENV_CONFIG_PATH =
5957
process.env.DOTENV_CONFIG_PATH ??
60-
path.resolve(opts.cwd, mode === 'production' ? '.env' : '.env.development');
61-
62-
// const tsConfigFile = path.resolve(opts.cwd, './tsconfig.json');
58+
path.resolve(
59+
opts.cwd,
60+
process.env.NODE_ENV === 'production' ? '.env' : '.env.development'
61+
);
6362

64-
webpackLogger.debug(`DOTENV_CONFIG_PATH %s`, DOTENV_CONFIG_PATH);
63+
// eslint-disable-next-line
64+
console.log(
65+
`Reading process.env from %s for %s (%s)`,
66+
DOTENV_CONFIG_PATH,
67+
path.basename(opts.cwd),
68+
Object.keys(opts.entry).join(', ')
69+
);
6570

6671
dotenv.config({ path: DOTENV_CONFIG_PATH });
6772

73+
D.enable(process.env.DEBUG ?? '');
74+
75+
const mode =
76+
process.env.NODE_ENV === 'production' ? 'production' : 'development';
77+
6878
const buildENV = pipe(
6979
{
7080
BUNDLE_TARGET: 'chrome',

0 commit comments

Comments
 (0)