Skip to content

Custom file resolvers

Choose a tag to compare

@tivac tivac released this 17 Feb 07:08
· 1099 commits to main since this release

It's now possible to pass an array of resolvers in as an option when using modular-css. This allows for resolving files in a different way from the default (node file resolution) to support some other use-cases.

For instance, in rollup:

rollup({
    // ...
    plugins : [
        require("modular-css/rollup")({
            css : "./output.css",

            resolvers : [
                (src, file, resolve) => ...
            ]
        })
    ]
})

A resolver function receives three arguments

  • src the file that the inclusion is based off of
  • file the path being included from src
  • resolve the default resolver function, in case that's useful for your resolver