Skip to content

Conversation

@florian-sanders-cc
Copy link
Contributor

@florian-sanders-cc florian-sanders-cc commented Dec 19, 2024

Fixes #1280

What does this PR do?

  • Removes the node-static dependency,
  • Removes the start npm script,
  • Adds .htaccess to be used by the static Clever App (Apache server).

How to review?

  • Check the code,
  • The preview shouldn't be impacted,
  • Run the npm run storybook:build locally and check that the storybook-static directory contains a .htaccess.

Things to discuss

To make Apache handle the SPA correctly & specify cache rules, we need a .htaccess file.
This .htaccess file needs to be placed at the root of the directory served by the server (CC_WEBROOT) which is storybook-static.

We cannot simply put the .htaccess in storybook-static ourselves because this directory is removed & created by the storybook build command (+ it's git ignored anyway).
We have two options:

  • make the build command copy the .htaccess file in storybook-static (the option I chose in this PR),
  • or add a CC_POST_BUILD_HOOK to move the .htaccess file in the storybook-static directory only when building on Clever Cloud.

The option I've chosen has 1 advantage: you cannot forget to add this step, it's part of the build process.
It also has 1 disadvantage: we send .htaccess files even for previews which is useless because they are served by Cellar.

@florian-sanders-cc florian-sanders-cc self-assigned this Dec 19, 2024
@florian-sanders-cc florian-sanders-cc force-pushed the storybook/switch-to-clever-static-app branch 3 times, most recently from e961265 to 0a313ed Compare December 19, 2024 10:05
@github-actions
Copy link
Contributor

🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/storybook/switch-to-clever-static-app/index.html.

This preview will be deleted once this PR is closed.

- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server),
- Adapt the storybook build process to copy the `.htaccess` file to the
  `storybook-static` directory.

Fixes #1280
@florian-sanders-cc florian-sanders-cc force-pushed the storybook/switch-to-clever-static-app branch from 0a313ed to 30bfb4b Compare December 19, 2024 10:19
Copy link
Contributor

@pdesoyres-cc pdesoyres-cc left a comment

Choose a reason for hiding this comment

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

LGTM. Well done.

The option you chose for the .htaccess file handling is ok for me.

Copy link
Member

@roberttran-cc roberttran-cc left a comment

Choose a reason for hiding this comment

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

Thanks for handling this! And I agree with the choice you made for the .htaccess.

@florian-sanders-cc florian-sanders-cc merged commit d1bfd5b into master Dec 19, 2024
4 checks passed
@florian-sanders-cc florian-sanders-cc deleted the storybook/switch-to-clever-static-app branch December 19, 2024 11:04
@github-actions
Copy link
Contributor

🔎 The preview has been automatically deleted.

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.

Storybook: static server crashes every now and then

3 participants