activeguild / vite-plugin-sass-dts

This is a plugin that automatically creates a type file when using the CSS module type-safely.
MIT License
120 stars 19 forks source link

Custom outputFilePath cause auto import style.d error #82

Closed truongnat closed 1 year ago

truongnat commented 1 year ago

Hi @activeguild,

Have good day <3,

I meet issue when using this library, i want custom outputFilePath from './src/style.d.ts' to './src/@types/style.d.ts'.

Because i move all file .d.ts to folder src/@types.

but custom above will error import when generate.

Screenshot 2023-07-28 at 00 19 18 Screenshot 2023-07-28 at 00 19 28 Screenshot 2023-07-28 at 00 20 22

i want change to:

Screenshot 2023-07-28 at 00 20 42

Thanks <3

truongnat commented 1 year ago

i found function getRelativePath, this function return relative path, but when to path includes @types or another folderm it still return ../..

export const getRelativePath = (
  from: string | undefined,
  to: string | undefined
) => {
  const relativePath =
    path.relative(path.dirname(from || ''), path.dirname(to || '')) || './'

  return relativePath.endsWith('..') ? `${relativePath}/` : relativePath
}
activeguild commented 1 year ago

@truongnat

Revised and published. Please check it.

truongnat commented 1 year ago

@truongnat

Revised and published. Please check it.

OKay thakns <