matheus23 / elm-tailwind-modules

Generate Elm code for Tailwind Utilities and Components that purges using Elm's dead code elimination!
https://matheus23.github.io/elm-tailwind-modules/
117 stars 12 forks source link

Fix tailwind-config option path resolution #2

Closed georgesboris closed 3 years ago

georgesboris commented 3 years ago

Fixes #1 .

Goal

Say a have a project with the structure like this:

/my-project
  package.json
  tailwind.config.js

This change makes it possible to call the --tailwind-config like this:

elm-tailwind-modules --tailwind-config ./tailwind.config.js

Problem

Currently, I need to specify to full relative path based on the internal structure of the publish elm-tailwind-modules package:

elm-tailwind-modules --tailwind-config ../../../tailwind.config.js

Why it was happening

Since the option accepts a regular string, by passing that value to await import the library was importing a file based on the current file position (e.g. node_modules/elm-tailwind-modules/dist/cli.js when using it as an external dependency). We need to the caller position so the imported path makes sense for the end user (e.g. calling it from an npm script).

matheus23 commented 3 years ago

Seems to work great! :tada:

Thank you very much! :)