histoire icon indicating copy to clipboard operation
histoire copied to clipboard

have an ability to specify "base directory"

Open jpengelbrecht opened this issue 2 years ago • 3 comments

Clear and concise description of the problem

currently if you build histoire in the index.html for example it has lines of code like , if for instance you want to host his as a sub directory on the same domain it currently breaks.

so for instance if you want to host your histoire on a url like /stories it will look for the above stylesheet in /assets instead of /stories/assets

Suggested solution

add a config property "base url". that allows this to be hosted as a sub domain which will append this value to the base directory.
so with a base url value of "/stories" the still import above becomes /stories/assets/style instead of /assets/style

Alternative

No response

Additional context

No response

Validations

jpengelbrecht avatar Feb 27 '24 11:02 jpengelbrecht

I think this is already possible. You can set a base path in the vite config, for example in the histoire.config.js:

import { defineConfig } from 'histoire';

export default defineConfig({
	vite: {
		base: '/stories/',
	},
});

theDevelopper avatar May 15 '24 10:05 theDevelopper

@theDevelopper that would be for the entire file. This would work if you are making a UI lib. But not if you have a base project that also makes use of historie. So ideally the historie build should have its own base path

jpengelbrecht avatar May 16 '24 09:05 jpengelbrecht

@jpengelbrecht Yes, I do understand that. that's why you can override the base path in the histoire.config.js instead of the project's vite.config.js, as shown in my example. This way the base path is applied to Histoire and not the project itself. At least in my project that works as expected.

theDevelopper avatar Jun 04 '24 06:06 theDevelopper