Skip to content

Commit

Permalink
fix: small misc fixes and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed May 20, 2020
1 parent 0f2a14c commit 7cbb05a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]",
Expand Down Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions src/loaders/sass/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/loaders/stylus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const loader: Loader<StylusLoaderOptions> = {

// 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/shims/stylus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export interface Options {
* - `"inject"` *(default)* - Embeds CSS inside JS and injects it into `<head>` 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.
Expand Down Expand Up @@ -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;
}

0 comments on commit 7cbb05a

Please sign in to comment.