stylus-bundle
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

stylus-bundle

Bundles all SCSS imports into a single file recursively. This is a fork of scss-bundle which now only supports non-cli usage. Any help appreciated.

NPM version

Total downloads

Dependencies

Dev dependencies

Non-CLI usage

This package now supports only non-CLI usage.

Simple example

import path from "path";
import { Bundler } from "stylus-bundle";
 
(async () => {
    // Absolute project directory path.
    const projectDirectory = path.resolve(__dirname, "./cases/tilde-import");
    const bundler = new Bundler(undefined, projectDirectory);
    // Relative file path to project directory path.
    const result = await bundler.bundle("./main.styl");
})();

API

Bundler

import { Bundler } from "stylus-bundle";

Constructor

constructor(fileRegistryFileRegistry = {}, projectDirectory?: string) {}
Arguments
  • fileRegistry?: Registry - Dictionary of files contents by full path
  • projectDirectory?: string - Absolute project location, where node_modules are located. Used for resolving tilde imports

Methods

bundle

public async bundle(filestring, fileRegistryRegistry = {})Promise<BundleResult>
Arguments
  • file: string - Main file full path
  • fileRegistry: Registry - Dictionary of files contents by full path
Returns

Promise<BundleResult>

Contracts

BundleResult

import { BundleResult } from "stylus-bundle";
interface BundleResult {
    imports?: BundleResult[];
    tilde?: boolean;
    filePath: string;
    content?: string;
    found: boolean;
}
Properties
  • imports: BundleResult[] - File imports array
  • tilde?: boolean - Used tilde import
  • filePath: string - Full file path
  • content: string - File content
  • found: boolean - Is file found

Registry

import { Registry } from "stylus-bundle";
interface Registry {
    [id: string]: string | undefined;
}
Key

id: string - File full path as dictionary id

Value

string | undefined - File content

License

Released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i stylus-bundle

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

22.2 kB

Total Files

6

Last publish

Collaborators

  • ledzz