Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: this set default values to the content of .env instead of .env.… #27

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
const fs = require('fs');
const dotenv = require('dotenv');
const path = require('path');
const { createConfig } = require('@edx/frontend-build');
const CopyPlugin = require('copy-webpack-plugin');

const config = createConfig('webpack-prod');

// The configuration is generated using the createConfig method from the frontend-build library,
// this method preloads multiple files to generate the resulting configuration, including webpack.common.config.js,
// https://github.com/nelc/frontend-build/blob/open-release/palm.nelp/config/webpack.common.config.js,
// which includes ParagonWebpackPlugin. This plugin, in turn, retrieves its configuration from the .env.development file
// https://github.com/nelc/frontend-build/blob/open-release/palm.nelp/lib/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.js#L20-L22
// Therefore, regardless of the configuration type, the plugin always utilizes data from .env.development.
// The following code overrides this behavior in order to use the .env file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now, it's really clear

const envConfig = dotenv.parse(fs.readFileSync('.env'));
Object.keys(envConfig).forEach(k => {
process.env[k] = envConfig[k];
});

Comment on lines +16 to +20
Copy link

@johanseto johanseto Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const envConfig = dotenv.parse(fs.readFileSync('.env'));
Object.keys(envConfig).forEach(k => {
process.env[k] = envConfig[k];
});
dotenv.config({
path: path.resolve(process.cwd(), '.env'),
override: true,
});

I think that could do the same,
inspired in this frontend build way
https://github.com/openedx/frontend-build/blob/v12.8.42/config/webpack.prod.config.js#L28-L30
but with override
https://github.com/openedx/frontend-build/blob/v12.8.42/config/webpack.prod.config.js#L28-L30

You could try...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the override feature was included in the 15.0.0 version we are in the 8.6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the way you did it, is the way.

config.plugins.push(
new CopyPlugin({
patterns: [
Expand Down
Loading