Sass imports from node_modules

オープン
#132 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, node.js, sass, webpack

調査の方向性

まず、参照されている行の周辺にある node-filing-cabinet の index.js の Sass ルックアップ関数を読み、その後 wp-calypso の bin/render-stylesheet.js にあるカスタムリゾルバーと比較します。node_modules からの Sass import と依存関係の場所が異なる場合のサポートをどこに実装すべきかを判断し、既存のディレクトリ処理を壊さずにそれらの import を解決できることを完了条件として定義します。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
JavaScript
スター
776
フォーク
82
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dependents/node-dependency-tree のほかの issue

dependents/node-dependency-tree の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。