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

Add remix.config.js back to templates #441

Merged
merged 2 commits into from
Feb 6, 2023
Merged

Add remix.config.js back to templates #441

merged 2 commits into from
Feb 6, 2023

Conversation

jplhomer
Copy link
Contributor

@jplhomer jplhomer commented Feb 3, 2023

We've been using the shopify hydrogen CLI to read and modify in-memory an app's remix.config.js values to support Oxygen deployments. We do this to:

  • Support defining Oxygen's base asset path at build time in production, which points to assets uploaded to the Shopify CDN
  • Support changing the default output directories to ones that Oxygen is looking for
  • Support the worker-based runtime, similar to Cloudflare workers

However, we've started thinking this type of "blackbox magic" is aligned with our standards for Hydrogen moving forward. Instead, it's better to be explicit about these settings and lean into existing Remix patterns.

Therefore, we should move these settings back to remix.config.js files in each of the templates.

Note: Some of these settings are not yet available in stable Remix remix-run/remix#4841, and thus won't quite work on their own. We're keeping out "magic" inside the Hydrogen CLI until they are stable, at which point we can remove them from the CLI.

It's most important to get these config files into the starter templates so that we don't have to issue a breaking change when we remove the functionality from the CLI at a later date.

@frandiox has started a PR demonstrating the changes using a nightly release of Remix: #437

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

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

Sounds good to me. I found in writing the proj structure that it would be nice to refer to this file (like for the public directory), but it wasn't there.

module.exports = {
appDirectory: 'app',
ignoredRouteFiles: ['**/.*'],
publicPath: (process.env.HYDROGEN_ASSET_BASE_URL ?? '/') + 'build/',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to confuse people?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can rename it to something else in our CLI? OXYGEN_CDN, SHOPIFY_CDN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would need to coordinate with the CS Admin team as they hardcode this in the Deployment GH Workflow for Oxygen

Copy link
Contributor

Choose a reason for hiding this comment

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

@jplhomer I mean we can add an alias in our CLI until all the other parts are aligned. But I guess we can just stick to HYDROGEN_ASSET_BASE_URL for the time being.

@frandiox
Copy link
Contributor

frandiox commented Feb 6, 2023

Since these are not really "options", should we add comments explaining not to change anything? Because it won't work if they change any of these values.

I can add a value validator to our CLI in another PR.

@frandiox
Copy link
Contributor

frandiox commented Feb 6, 2023

Also, let's add the same file for the skeleton template so that we can run it locally.

@jplhomer jplhomer merged commit 9abc7d5 into 2023-01 Feb 6, 2023
@jplhomer jplhomer deleted the jl-remix-config branch February 6, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants