Sass imports from node_modules
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, node.js, sass, webpack
- Domain
- build-system, tooling
Research direction
Start by reading the Sass lookup function in node-filing-cabinet's index.js around the referenced line, then compare it with the custom resolver in wp-calypso's bin/render-stylesheet.js. Determine where support for Sass imports from node_modules and varying dependency locations belongs, and define completion around resolving those imports without breaking existing directory handling.
Written by the indexing model from the issue text.
Description
Howdy! In sass, you can use sass-loader with Webpack to resolve Sass imports from node modules. This can look something like the following:
@import 'npm-package/stylesheet'
// etc
This should resolve to node_modules/npm-package/stylesheet.scss. Unfortunately, cabinet + sass-lookup doesn't quite handle this use case. You can get it to resolve using just cabinet, by passing node_modules as a directory, but dependency tree doesn't accept multiple directories in general, so that won't work for our use case. I was wondering what a good path would be towards implementing support.
A really naive implementation could be something like this as the lookup function for sass in cabinet.
function sassResolver(options) {
let { directory } = options;
if (typeof directory === 'string') {
directory = [ directory ];
}
directory.push( 'node_modules' );
return sassLookup({ ...options, directory })
}
This does work, but it wouldn't be able to handle different node_modules locations, such as in monorepos. One could also add a custom resolver like this: https://github.com/Automattic/wp-calypso/blob/6ef9f9278aaf368cd629ba69c33c4768dc7ea08d/bin/render-stylesheet.js#L16-L23. But I'm not sure where exactly to put that -- would the sass-lookup package be a good fit?
What are your thoughts?
- Dominant language
- JavaScript
- Stars
- 776
- Forks
- 82
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dependents/node-dependency-tree
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
question
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
question
Difficulty 3/5 1-2 days Newbie friendliness 25/100
dependents/node-dependency-tree#152 · 2 comments ·
-
Why is precinctOptions.includeCore always false?May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
All issues in dependents/node-dependency-tree
Similar issues
-
ai core enhancement good first issue testing
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
cli: `studio --request <missing file>` answers with a raw ENOENT/EISDIR instead of a clear errorPossibly taken A pull request linked to this issue is open or already merged. Openbug good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
laaielichter/Ai-edit-studio#81 ·
Maintainers usually reply within 1 day