cap-rollup-config

1.1.1 • Public • Published

npm libera manifesto

cap-rollup-config

A Rollup configurator that provides everything needed for modern web development. It includes legacy bundles for IE11 and a dev server with live reload.

Install

Using npm:

npm install cap-rollup-config --save-dev

Usage

Create a rollup.config.js configuration file and import the configurator:

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig();

Then call rollup either via the CLI or the API.

Calling rollup with the --watch flag will start the dev server that will reload any open browser when any bundled file changes.

Options

assetsDir

Type: String
Default: src/assets

Path to the directory where the project's assets are stored.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  assetsDir: 'src/assets'
});

entryDir

Type: String
Default: src

Path to the directory where the project's source is stored.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  entryDir: 'src'
});

entryFileName

Type: String
Default: index

Name of the JS file that's the entry point for of the project.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  entryDir: 'index'
});

outputDir

Type: String
Default: build

Path to the directory where the build should be stored. Note that the folder's contents will be deleted when a build is triggered.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  outputDir: 'build'
});

outputFileName

Type: String
Default: index

Name of the main bundle generated on build. Note that a second bundle will be generated following the format [outputFileName].legacy.js to be used in older browsers like IE11.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  outputFileName: 'index'
});

host

Type: String
Default: localhost

Hostname of the dev server to be used when running rollup with --watch flag.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  host: 'localhost'
});

port

Type: Number
Default: 4200

Port of the dev server to be used when running rollup with --watch flag.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  port: 4200
});

extender

Type: Function
Default: (pluginConfig) => pluginConfig

Method that can be used to extend the given configuration for each plugin. It will receive the plugin configuration object as the first parameter and the configuration name as the second parameter.

import { getRollupConfig } from 'cap-rollup-config';
 
export default getRollupConfig({
  extender: (pluginConfig, configName) => {
    switch(configName) {
      case 'copy':
        return {
          ...pluginConfig,
          // Add some more properties to the configuration object
        };
      case default:
        // Don't forget to always return the plugin config as the
        // method is called for every configuration
        return pluginConfig;
    }
  }
});

Meta

LICENSE (ISC)

Package Sidebar

Install

npm i cap-rollup-config

Weekly Downloads

0

Version

1.1.1

License

ISC

Unpacked Size

24.6 kB

Total Files

10

Last publish

Collaborators

  • mmirca