From 7cbb05a6269c40b22e03acc84b45fedb82277aeb Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 21 May 2020 01:42:46 +0300 Subject: [PATCH] fix: small misc fixes and changes --- README.md | 6 +++--- src/loaders/sass/importer.ts | 6 ++---- src/loaders/stylus.ts | 2 +- src/shims/stylus.d.ts | 2 +- src/types.ts | 6 +++--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 480d0b85..c71e4542 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ - URL resolving/rewriting with asset handling - Ability to use `@import` statements inside regular CSS -...and much more! +...and more! ## Table of Contents @@ -58,7 +58,7 @@ import styles from "rollup-plugin-styles"; export default { output: { // Governs names of CSS files (for assets from CSS use `hash` option for url handler). - // Note: using value below will put .css files near js, + // Note: using value below will put `.css` files near js, // but make sure to adjust `hash`, `assetDir` and `publicPath` // options for url handler accordingly. assetFileNames: "[name]-[hash][extname]", @@ -120,7 +120,7 @@ Also note that partials are considered first, e.g. @import "custom"; ``` -Will look for `_custom` first _(with the approptiate extension(s))_, and then for `custom` if `_custom` doesn't exist. +Will look for `_custom` first (_with the approptiate extension(s)_), and then for `custom` if `_custom` doesn't exist. ### CSS Injection diff --git a/src/loaders/sass/importer.ts b/src/loaders/sass/importer.ts index ac2558da..011bae23 100644 --- a/src/loaders/sass/importer.ts +++ b/src/loaders/sass/importer.ts @@ -17,10 +17,8 @@ const importer: sass.Importer = (url, importer, done) => { // Give precedence to importing a partial resolveAsync(partialUrl, options) .then(finishImport) - .catch(error => { - if (error.code === "MODULE_NOT_FOUND" || error.code === "ENOENT") - resolveAsync(moduleUrl, options).then(finishImport).catch(next); - else next(); + .catch(() => { + resolveAsync(moduleUrl, options).then(finishImport).catch(next); }); }; diff --git a/src/loaders/stylus.ts b/src/loaders/stylus.ts index 298ac0c4..674dc664 100644 --- a/src/loaders/stylus.ts +++ b/src/loaders/stylus.ts @@ -32,7 +32,7 @@ const loader: Loader = { // We have to manually modify the `sourcesContent` field // since stylus compiler doesn't support it yet - if (style.sourcemap?.sources) { + if (style.sourcemap?.sources && !style.sourcemap.sourcesContent) { style.sourcemap.sourcesContent = await Promise.all( style.sourcemap.sources.map(async source => { try { diff --git a/src/shims/stylus.d.ts b/src/shims/stylus.d.ts index 1f177113..4410cfca 100644 --- a/src/shims/stylus.d.ts +++ b/src/shims/stylus.d.ts @@ -11,7 +11,7 @@ declare namespace stylus { }; } - type Callback = (err: Error, css: string, js: string) => void; + type Callback = (err: Error, css: string) => void; interface Renderer { render(callback: Callback): void; diff --git a/src/types.ts b/src/types.ts index 4977e4cd..84da3bf7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -207,7 +207,7 @@ export interface Options { * - `"inject"` *(default)* - Embeds CSS inside JS and injects it into `` at runtime. * You can also pass options for CSS injection. * Alternatively, you can pass your own CSS injector. - * - `"extract"` - Extract CSS to the same location where JS file is generated but with .css extension. + * - `"extract"` - Extract CSS to the same location where JS file is generated but with `.css` extension. * You can also set extraction path manually, * relative to output dir/output file's basedir, * but not outside of it. @@ -314,8 +314,8 @@ export interface Options { */ onImport?: (code: string, id: string) => void; /** - * Function which is invoked on CSS file export. - * Return `boolean` to control if file should be exported or not. + * Function which is invoked on CSS file extraction. + * Return `boolean` to control if file should be extracted or not. */ onExtract?: (data: ExtractedData) => boolean; }