Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rollup/plugin-replace

Package Overview
Dependencies
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-replace

[cover]: https://codecov.io/gh/rollup/plugins/branch/master/graph/badge.svg [cover-url]: https://codecov.io/gh/rollup/plugins [size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-replace [size-url]: https://packagephobia.now.sh/result?p=@rollup/plu

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6M
decreased by-7.76%
Maintainers
4
Weekly downloads
 
Created

What is @rollup/plugin-replace?

The @rollup/plugin-replace npm package allows you to replace strings in files while bundling them with Rollup. This can be particularly useful for inserting environment variables, toggling between development and production modes, or any scenario where you need to dynamically alter your code at build time.

What are @rollup/plugin-replace's main functionalities?

Environment Variable Replacement

This feature allows you to replace occurrences of 'process.env.NODE_ENV' with 'production' in your code. It's particularly useful for setting the environment mode.

import replace from '@rollup/plugin-replace';

export default {
  plugins: [
    replace({
      'process.env.NODE_ENV': JSON.stringify('production')
    })
  ]
};

Conditional Code Inclusion/Exclusion

This feature enables you to conditionally include or exclude code blocks based on the replacement. In this example, all blocks guarded by 'if (process.env.DEBUG)' will always execute as if the condition is true.

import replace from '@rollup/plugin-replace';

export default {
  plugins: [
    replace({
      'if (process.env.DEBUG)': 'if (true)'
    })
  ]
};

Other packages similar to @rollup/plugin-replace

Keywords

FAQs

Package last updated on 06 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc