frctl / fractal

A tool to help you build and document website component libraries and design systems.
https://fractal.build
MIT License
2.11k stars 170 forks source link

`index.html` file in `static.path` setting causes Web UI to not load. #133

Closed radarseven closed 6 years ago

radarseven commented 8 years ago

Hey Guys,

So, the use case is the following directory setup:

/fractal
 - /build
 - /docs
 - /src
/public
 - .htacess
 - /assets
  - /css
  - /js
  - /img
 index.html

With the following Fractal config:

/* Create a new Fractal instance and export it for use elsewhere if required */
const fractal = module.exports = require('@frctl/fractal').create();

/* Web assets */
fractal.web.set('static.path', __dirname + '/public');

However, when trying to load the Web UI on http://localhost:3000, the file /public/index.html prevents the Web UI from loading the component library and is loaded instead.

I tried modifying /public/.htacess with DirectoryIndex index.js index.html, but no dice. Is there any way around this issue? I assume it had something to do with how the Web UI is being loaded up.

allmarkedup commented 8 years ago

Hey @radarseven - you can specify a 'mount' URL for the static files in the public directory, which might solve your problem. For example:

fractal.web.set('static.path', __dirname + '/public');
fractal.web.set('static.mount', '/static');

Now anything in your public directory will be available at a URL that is prefixed by the path (in this example ) /static. For example, a stylesheet at public/assets/css/foo.css will now be served at the URL /static/assets/css/foo.css.

Would that help solve the issue?

radarseven commented 8 years ago

Hey @allmarkedup, thanks for the response.

I don't "think" that actually helps me. The reason is, I'm using the public directory for production-ready builds. So, if I set static.mount to /static, then all of my path references in SCSS to those assets, i.e. images, etc. won't work after building to a static export.

Am I thinking about this incorrectly? The only issue I'm running into is that /public/index.html prevents the server from loading correctly when working locally. Perhaps there's a better way around that issue?

xar commented 7 years ago

I have same issue @radarseven have you found any solution for that ? My case is that I have js application which is at the end bundlel to /dist folder. With index.html, css/, js/ but when I set public.path to that directory fractal will load dist/index.html as default page 🤔

mikaelkarlsson-se commented 7 years ago

I've also encountered this problem and would really need a solution. My project setup is nearly identical to @xar and when I set static.path to /dist (to be able to load compiled CSS and JS) it won't work if I also have a index.html file in that folder.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

anischohan commented 3 years ago

Just an fyi, using mount worked for me :) thank you for this.