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

Configuration-Driven Running Modes/Profiles #2531

Closed
x80486 opened this issue Jun 23, 2024 · 2 comments
Closed

Configuration-Driven Running Modes/Profiles #2531

x80486 opened this issue Jun 23, 2024 · 2 comments

Comments

@x80486
Copy link

x80486 commented Jun 23, 2024

Description

Currently, when Fresh project is generated, a dev.ts and main.ts files are created — along with some related tasks. These files are intuitive enough to figure it out what's their role within the project.

The dev.ts file looks very much like something users shouldn't have to deal with directly because it reflects a way to run the application. I think this approach could be streamlined because Fresh already has a configuration file. Basically, Fresh could be able to hide all this and have a single entrypoint by introducing the notion of running modes (or something similar), driven by the configuration file and some flag specified in a task when the application is run.

This could lead to a more declarative configuration, where things like dotenv (usually only used for local development) and things like that are meant to be used only, let's say in dev mode, and some others won't be used in prod or test mode — just throwing ideas.

// fresh.config.js
export default defineConfig({
  modes: {
    dev: {
      loadModules: ["dotenv"],
      envFile: ".env"
      watch: ["components", "routes", "static"]
    }
    prod: {
      // ...
    },
    test {
      loadModules: ["dotenv"]
      envFile: ".env"
    }
  }
});

I'm not sure how complex this could be, or if it aligns with how you would like Fresh to behave in general, but it certainly reduces boilerplate code (for users) and makes environment management more intuitive — twelve-factor app, etc.

@marvinhagemeister
Copy link
Collaborator

You might be happy to hear that this has been cleaned up a bit with the upcoming Fresh 2 release. The code has already landed in the main branch and can be checked out. We got rid of the config file all together and moved everything dev related into dev.ts and anything else into main.ts.

@x80486
Copy link
Author

x80486 commented Jun 23, 2024

Looking forward Fresh 2.0 release! 👌

@x80486 x80486 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment