Skip to content

Commit

Permalink
fix(stylus): respect local node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed May 15, 2020
1 parent 554b0a6 commit eebbbed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/loaders/stylus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const loader: Loader<StylusLoaderOptions> = {
if (!stylus)
throw new Error("You need to install `stylus` package in order to process Stylus files");

const basePath = normalizePath(path.dirname(this.id));

const style = stylus(code, { ...this.options })
.set("filename", this.id)
.set("sourcemap", { comment: false, basePath: path.dirname(this.id) });
.set("paths", [`${basePath}/node_modules`, basePath].concat(this.options.paths ?? []))
.set("sourcemap", { comment: false, basePath });

const render = async (): Promise<string> =>
new Promise((resolve, reject) => {
Expand Down
17 changes: 5 additions & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ export type PostCSSLoaderOptions = {

/** Options for Sass Loader */
export type SASSLoaderOptions = {
/**
* Sass importer, or array of such
* @default undefined
*/
/** Sass importer, or array of such */
importer?: SASSImporter | SASSImporter[];
/**
* Data to prepend to every Sass file
* @default undefined
*/
/** Data to prepend to every Sass file */
data?: string;
/** Force Sass implementation */
impl?: "node-sass" | "sass";
Expand All @@ -89,16 +83,15 @@ export type SASSLoaderOptions = {

/** Options for Stylus loader */
export type StylusLoaderOptions = {
/** Array of paths for Stylus */
paths?: string[];
/** Any options for `stylus` processor */
[option: string]: unknown;
};

/** Options for Less Loader */
export type LESSLoaderOptions = {
/**
* Array of Less plugins
* @default undefined
*/
/** Array of Less plugins */
plugins?: LESSPlugin[];
/** Any options for `less` processor */
[option: string]: unknown;
Expand Down

0 comments on commit eebbbed

Please sign in to comment.