Socket
Socket
Sign inDemoInstall

rollup-plugin-replace

Package Overview
Dependencies
8
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rollup-plugin-replace

Replace strings in files while bundling them.


Version published
Weekly downloads
72K
increased by8.27%
Maintainers
1
Install size
667 kB
Created
Weekly downloads
 

Changelog

Source

1.2.1

  • Match longest keys first (#8)
  • Escape keys (#9)

Readme

Source

rollup-plugin-replace

Replace strings in files while bundling them.

Installation

npm install --save-dev rollup-plugin-replace

Usage

Generally, you need to ensure that rollup-plugin-replace goes before other things (like rollup-plugin-commonjs) in your plugins array, so that those plugins can apply any optimisations such as dead code removal.

// rollup.config.js
import replace from 'rollup-plugin-replace';

export default {
  // ...
  plugins: [
    replace({
      ENVIRONMENT: JSON.stringify( 'production' )
    })
  ]
};

Options

{
  // a minimatch pattern, or array of patterns, of files that
  // should be processed by this plugin (if omitted, all files
  // are included by default)...
  include: 'config.js',

  // ...and those that shouldn't, if `include` is otherwise
  // too permissive
  exclude: 'node_modules/**',

  // To replace every occurence of `<@foo@>` instead of every
  // occurence of `foo`, supply delimiters
  delimiters: [ '<@', '@>' ],

  // All other options are treated as `string: replacement`
  // replacers...
  VERSION: '1.0.0',
  ENVIRONMENT: JSON.stringify( 'development' ),

  // or `string: (id) => replacement` functions...
  __dirname: (id) => `'${path.dirname(id)}'`,

  // ...unless you want to be careful about separating
  // values from other options, in which case you can:
  values: {
    VERSION: '1.0.0',
    ENVIRONMENT: JSON.stringify( 'development' )
  }
}

License

MIT

Keywords

FAQs

Last updated on 05 Sep 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc