npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

config-helper-rollup

v0.0.38-alpha

Published

Quite a bit under construction. Beware - no guarantees, no semver (or even proper versioning) (yet)

Downloads

45

Readme

Config Helper Rollup - simple Rollup Configurations

Description

Config Helper Rollup is a helper function to create configurations for the bundler Rollup. Submitting settings to this API creates readable, modifiable and working rollup configurations.

The API helps with settings for

  • styles
  • minification
  • development server
  • html template
  • svelte
  • jsx (in effect, React)
  • TypeScript

Contents

-

Installation

Install as a devDependency using npm:

npm i config-helper-rollup -D

Usage

In your rollup.config.js file, import chr, and export a configuration (or array of configurations):

import { chr } from "config-helper-rollup";
export default [
    chr("myApp").end(),
];

The above is calling the builder API, with all default options, and finally invoking end() to produce an actual rollup configuration object.

To make the resulting configuration include settings for anything like styles, templates, svelte, jsx or TypeScript, supply a corresponding options object - or use the chaining syntax:

chr("myApp", {
    styles: true,
    htmlTemplate: true,
}).end();

// or

chr("myApp")
    .styles()
    .htmlTemplate()
    .end();

Helpful entries in npm's package.json scripts are:

// package.json, excerpt
---- >8
"scripts": {
    "clean": "rm -rf ./dist",
    "build": "rollup -c",
    "dev": "npm run build -- -w --environment NODE_ENV:development
}
8< ----

Options

The signature of chr is

chr: (appName: string, options: IOptions) => IIntermediateResult;

The appName corresponds to a plain Rollup config's output.name property, and thus should be a string that is also a valid JavaScript identifier.

The options signature is

interface IOptions {
    // Base options
    src?: string;                   // default "./src"
    dist?: string;                  // default "./dist"
    entry?: string;                 // default "main.js"
    sourcemap?: boolean;            // default: true 
    production?: boolean | string;  // default: "NODE_ENV"
    minify?: boolean;               // default: true if production mode, false otherwise (see "production" option) 
    
    // Plugin options
    styles?: boolean | IStylesOptions;              // default: false
    htmlTemplate?: boolean | IHtmlTemplateOptions;  // default: false
    devServer?: boolean | IDevServerOptions;        // default: false
    svelte?: boolean | ISvelteOptions;              // default: false
    jsx?: boolean | IJsxOptions;                    // default: false
    ts?: boolean | ITsOptions;                      // default: false
    
}
Base options

| prop | description | |------------|----------------------| | src | the source directory | | dist | the build directory, to which all processed files are written | | entry | the main entry filename (in the src directory) | | production | used to determine prod/dev mode. It is either a "hard boolean", or a string indicating which node.env property to look at. If that property is anything but "development", mode is considered to be production. | | minify | whether to minify written files. If not supplied, it will be deduced from whether mode is production (true) or not (false). |

Plugin options

styles
interface IStyleOptions {
    autoModules?: RegExp;   // default: /.+\.module\..+/
    extract?: boolean;      // default: true
    sourceMap?: boolean;    // default: true
    minify?: boolean;       // default: deduced from the Base option "minify"
}

| prop | description | |------|-------------| | autoModules | Regexp to match style file names which should be treated ass css modules | | extract | whether to extract styles to a file ow its own | | sourceMap | whether to generate sourcemaps for styles | | minify | whether to minify the content in bundles written |

Example:

chr("myApp", {
    styles: {
        minify: false,
    }    
});

// or, using the chaining style API:
chr("myApp")
    .styles({
        minify: false,
    });
htmlTemplate
interface IHtmlTemplateOptions {
    template?: string;  // default: "index.html"
    page?: string;      // default: "index.html"
}

| prop | description | |------|-------------| | template | template filename (in src directory) | | page | output html file name (in distdirectory) |

Example:

chr("myApp", {
    htmlTemplate: {
        template: "index.v2.html",
    }
});

// or, using the chaining style API:
chr("myApp")
    .htmlTemplate({
        template: "index.v2.html",
    });
devServer
interface IDevServerOptions {
    port?: number;          // default: 3000
    livereload?: boolean;   // default: true
}

| prop | description | |------|-------------| | port | port on which to start development server | | livereload | whether to use livereload |

Example:

chr("myApp", {
    devServer: {
        port: 8001,
    }
});

// or, using the chaining style API:
chr("myApp")
    .devServer({
        port: 8001,
    });
svelte
interface ISvelteOptions {
    cssFileBaseName?: string;   // default: deduced from the submitted base "appName" setting 
}

| prop | description | |------|-------------| | cssFileBasename | base name of generated css file. Will result in <baseName>.svelte.css (in dist directory) |

Example:

chr("myApp", {
    svelte: {
        cssFileBaseName: "styles",
    }
});

// or, using the chaining style API:
chr("myApp")
    .svelte({
        cssFileBaseName: "styles",
    }) 
jsx
interface IJsxOptions {}

| prop | description | |------|-------------| | | |

Example

chr("myApp", {
    jsx: true,
});

// or, using the chaining style API:
chr("myApp")
    .jsx();
ts
interface ITsOptions {}

| prop | description | |------|-------------| | | |

Example:

chr("myApp", {
    ts: true,
});

// or, using the chaining style API:
chr("myApp")
    .ts();

License

License: Finally, include a section for the license of your project. For more information on choosing a license, check out GitHub’s licensing guide!