mpetrovich / stylemark

Generate interactive style guides from Markdown.
MIT License
218 stars 35 forks source link

Improved baseDir path #57

Closed Cyclodex closed 5 years ago

Cyclodex commented 6 years ago

Context

In our bigger project, the file structure doesn't allow us to put the stylemark folder next to the node_modules, which seems to be a problem when loading assets.

Problem

Without this PR, the styleguide will copy the assets including the folder "SubProject1". However, when you are within SASS/LESS/CSS etc. you don't mention the SubProject1 folder in filepaths, because its outside of the "Webroot". This makes it not really possible to load images, reference fonts etc.

Solution

Improved baseDir handling within options, so it doesn't go out to the package.json location.

I found out that I can solve the problem with removing the findRoot function call when the options.baseDir is set. (otherwise it will search the node_modules folder)

Assets can now be in any location, the baseDir option allows to improve the path of copied assets, especially if assets are not based on root path

Example setup

This can now be solved with stylemark.yml settings and this PR: Set the baseDir, and don't mention the baseDir within the assets:

baseDir: SubProject1

assets:
 - SubProject1/images
 - SubProject1/fonts

Feature Sponsored by

If you like this change, feel free to review and accept this PR ;) This feature/PR is sponsored by the company I work: Garaio AG

mpetrovich commented 5 years ago

Released in v3.1.0