🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

rollup-plugin-block

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-block

Ensure certain files don't become part of the build.

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

npm version Greenkeeper badge

rollup-plugin-block

Ensure certain files don't become part of the build.

Why?

Sometimes you want to have separate builds for dev and production. You might use the replace plugin to conditionally import certain files. This plugin lets you make sure that a file that is meant for one build isn't accidentally compiled into another.

Example

In this example if the __DEV_MODE__ check was missing, the non-dev build would fail because it would contain "debug-logger.devonly.js". With the __DEV_MODE__ check "debug-logger.devonly.js" would be omitted from the build by rollup given it's unused.

main.js

import { debugLogger } from './debug-logger.devonly.js';

if (__DEV_MODE__) {
  debugLogger.log('In dev mode.');
}

debug-logger.devonly.js

export const debugLogger = {
  log: msg => console.log(msg)
};

rollup.config.js

import rollupPluginBlock from 'rollup-plugin-block';
import replace from 'rollup-plugin-replace';

export default {
  input: 'main.js',
  plugins: [
    replace({
      __DEV_MODE__: JSON.stringify(!!process.env.DEV_BUILD)
    }),
    rollupPluginBlock({
      blockPattern: '.devonly.'
    })
  ]
};

Installation

npm install --save-dev rollup-plugin-block

Usage

import { rollup } from 'rollup';
import rollupPluginBlock from 'rollup-plugin-block';

export default {
  input: 'main.js',
  plugins: [
    rollupPluginBlock({
      blockPattern: '.devonly.' // or regex
    })
  ]
});

Keywords

rollup-plugin

FAQs

Package last updated on 24 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts