0.0.16 ā€¢ Published 5 years ago

@brikcss/rollup-config-generator v0.0.16

Weekly downloads
17
License
MIT
Repository
github
Last release
5 years ago

Rollup Config Generator

About

āš ļø IMPORTANT: Brikcss follows semantic versioning. This package is currently at major version zero, which means "anything may change at any time", and it "should not be considered stable".

Rollup config generator makes it easy to generate complex configurations for RollupJS.

Contributing šŸ™

We ā¤ļøā¤ļøā¤ļø contributions of any kind, whether it's bug reports, questions or feature requests, pull requests, and especially spreading some love about this project to your friends and co-workers!

Read our contributing guidelines and get involved to support this project.

Environment support

NodeCLIBrowserUMDES Module
āœ…āŒāŒāœ…āŒ

Install šŸ“¦

npm install -D @brikcss/rollup-config-generator

Quick Start šŸ

Get up and running in less than five minutes:

  1. Create a new generator in your rollup config file:

    Create new generator with all defaults:

    import configGen from "@brikcss/rollup-config-generator";

    Or Create a custom generator:

    import { ConfigGen } from "@brikcss/rollup-config-generator";
    const configGen = new ConfigGen({ base, sets, options, on });
  2. Create the configuration and export it from your rollup config:

    export default configGen.create(userConfig, globals);

API šŸ¤–

Note: ConfigGen contains many methods which are not documented here. Check out the source code to see what else is available.

Generate configs

const rollupConfigs = ConfigGen.create(userConfigs, globals);
  • userConfigs {object[]} (required) Array of user config objects. Each config object can contain any of Rollup's configuration options, as well as the following:

    • id {string} If ConfigGen cannot find a filepath from package.json that can be used, the id is used to help generate the output.file (if not already set).
    • type {string} If this is set, ConfigGen will create a "set" of rollup configs by looking up ConfigGen.sets[type] and merging with the base and default config settings. By default, type can be browser, dependency, or node, though custom sets can be created. See creating a custom generator.
    • target {string} If target is set, Babel will be set up to compile the bundle for the specified environment. Possible values are: modern (modern browsers), legacy (legacy browsers), or a number (e.g., 9) which determines the minimum node version to target.
  • globals {object} When a rollup config is compiled, if a property in globals matches ${output.format} or ${output.format}:${config.modern}, that object is merged with the rest of the rollup config. For example: globals.esm will be merged with all rollup configs where output.format is esm. Likewise, globals['esm:modern'] will merge with all rollup configs where output.format is esm AND where config.target is modern.

Create a custom generator

const configGen = new ConfigGen({ base, sets, options, on });
  • base {object} Base configuration. This gets merged with every rollup config that gets created. See source code for default values.
  • sets {object} Configuration sets. This allows you to create multiple rollup configs with a single user config object. In a user config object, if the type property exists, configs will be generated for each object in a set. The default sets are:

    • browser: Creates a source ESM build, as well as separate ESM and UMD builds which target both modern and legacy browsers. This should be used for modules that are intended for use in the browser.
    • dependency: Browser dependency builds. Since browsers do not resolve node module imports, this prebundles browser dependencies as ESM (modern only) and UMD (modern and legacy) builds. This can be used for any production dependencies you wish to provide prebundled.
    • node: Node builds. This generates builds intended for use in a CommonJS/Node environment.
  • options {object} Configuration options:

    • options.outputDir {string} dist Output directory.
    • options.pkgMap {object} For each user config, ConfigGen checks ${output.format} and ${output.format}:${config.type} in package.json. If the field exists, that filepath is used for output.file.
  • on {object} Map of the following hooks/callbacks:

    • prependPlugins {function} (config) => newPlugins Prepends plugins to config.plugins.
    • insertPlugins {function} (config) => newPlugins Inserts plugins to config.plugins.
    • appendPlugins {function} (config) => newPlugins Appends plugins to config.plugins.
    • output {function} (output, config) => output Modifies config.output.

License šŸ“ƒ

See License.

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago