Skip to content

Support lightningcss "resolver" option #16593

Open
@olivierbossel

Description

Description

Hi their!
Hope you are doing well! At start, thanks for your work!

It will be nice to be able to specify the resolver options supported by the lightningcss compiler but that seems to be not passed and supported on the vite side...

export type LightningCSSOptions = {

Suggested solution

Add the resolver option in the LightningCSSOptions type as well as passing it to the lightningcss compiler.

Alternative

No response

Additional context

Example of use:

// vite.config.ts
import { browserslistToTargets } from "lightningcss";
import fs from 'fs';
import path from 'path';

export default {
  css: {
    transformer: "lightningcss",
    lightningcss: {
      resolver: {
        read(filePath) {
          console.log(filePath);
          return fs.readFileSync(filePath, "utf8");
        },
        resolve(specifier, from) {
          return path.resolve(path.dirname(from), specifier);
        },
      },
      targets: browserslistToTargets(browserslist(">= 0.25%")),
    },
  },
  build: {
    cssMinify: "lightningcss",
  },
};

Validations

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions