web icon indicating copy to clipboard operation
web copied to clipboard

[dev server rollup] Custom plugins cannot load source files from outside the project root

Open aearly opened this issue 3 years ago • 0 comments

I have a custom LessCSS Rollup plugin that loads .less files and converts them to exported string literals. I am setting up a monorepo, and found that no .less files outside the project root were not being resolved properly. The plugin would receive paths like /path/to/my/project/packages/foo/__wds-outside-root__/2/shared/styles/foo.less, which would fail to resolve.

It looks like the the serve method of the rollupPluginAdapter does not resolve the __wds-outside-root__ paths before passing the path to a wrapped plugin's load method. For now I'm working around this in my custom plugin, but it was very hard to track down the root cause. The .less files were being served as-is, rather than being converted to JS modules that export string literals.

aearly avatar Feb 04 '22 18:02 aearly