JensAstrup / shortcut-assistant

A Chrome extension that adds features for power users of Shortcut
https://www.shortcut-assistant.jensastrup.io/
Other
4 stars 0 forks source link

Fix webpack config #457

Closed JensAstrup closed 3 months ago

JensAstrup commented 3 months ago

What's Changed

Tested

github-actions[bot] commented 3 months ago

The updates made to both webpack.config.base.js and webpack.config.js show an effort to refine and streamline the environment variables loading process through dotenv and dotenv-webpack. Here are some observations and feedback on these changes:

webpack.config.base.js

  1. Adding Dotenv and Environment Configuration:

    • The addition of dotenv-webpack and the setup to specify environment variable files (envFiles) based on the NODE_ENV is a good practice. This allows for more flexible configuration management across different environments (development, staging, production) without hardcoding paths or values within the codebase. It centralizes environment-specific configurations in external files, making the management of such configurations much easier and more secure.
  2. Code Organization:

    • Organizing the import and immediate configuration of environment-related settings at the top of the file improves readability and maintainability. It sets a clear precedent for the order of operations; environment variables are configured before they are possibly used in subsequent configurations.
  3. Environment Variables Loading:

    • The use of require('dotenv').config({ path: envFile }) immediately after defining envFile ensures that the environment variables from the specified file are loaded before the rest of the webpack configuration is executed. This explicit loading is crucial for ensuring that any code depending on environment variables can safely assume these variables are already set.

General Suggestions for Improvement:

Positive Feedback:

Overall, these changes are constructive, align with best practices for web application development, and contribute to a more organized and maintainable codebase.