Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using external importers #252

Open
phmasek opened this issue Jan 31, 2024 · 1 comment
Open

Using external importers #252

phmasek opened this issue Jan 31, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@phmasek
Copy link

phmasek commented Jan 31, 2024

Is your feature request related to a problem? Please describe.
My setup implements node-sass-json-importer. The project is a NextJS project and the implementation is setup through the next.config.mjs file. I can't implement the importer via tsconfig.json as it only takes strings. The plugin fails to generate types to .scss that tries to import a JSON file, which works elsewhere due to the implementation of the importer.

Describe the solution you'd like
The string value added as the example below, shall successfully import and implement the importer at initialisation.

{
  "name": "typescript-plugin-css-modules",
  "options": {
    "customMatcher": "\\.module\\.scss$",
    "rendererOptions": {
      "sass": {
        "includePaths": ["src"],
        "importer": "node-sass-json-importer",
      },
    },
  },
}

Describe alternatives you've considered

  • Possibly extending the tsconfig in webpack configuration through next.config.msj.
  • Be able to ignore specific lines so that the plugin does not throw error.
@mrmckeb
Copy link
Owner

mrmckeb commented Feb 11, 2024

Hi @phmasek, this is indeed an interesting one.

I can see two paths forward here.

Easy
If a string is passed, we resolve it and then call the function - passing that into importers. The limitation of this would be that you wouldn't be able to provide options to the importer, and it would only work if it was the default export.

Hard
We support JS configuration files for this plugin, which it sounds like we may need to do for flexibility.

Would the easy option solve this for you today? Or do you need to provide options?

@mrmckeb mrmckeb added the enhancement New feature or request label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants