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

rollup-plugin-replace

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-replace

[![](https://img.shields.io/npm/v/rollup-plugin-replace.svg?style=flat)](https://www.npmjs.com/package/rollup-plugin-replace)

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is rollup-plugin-replace?

The rollup-plugin-replace package is a Rollup plugin that allows you to replace strings in files while bundling. This is particularly useful for replacing environment variables or other constants in your code during the build process.

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

Replace Environment Variables

This feature allows you to replace environment variables in your code. In the example, the `process.env.NODE_ENV` variable is replaced with the string 'production'. This is useful for setting different configurations for development and production environments.

import replace from 'rollup-plugin-replace';

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

Replace Custom Strings

This feature allows you to replace custom strings in your code. In the example, the `__buildDate__` placeholder is replaced with the current date. This can be useful for embedding build metadata directly into your code.

import replace from 'rollup-plugin-replace';

export default {
  plugins: [
    replace({
      '__buildDate__': () => JSON.stringify(new Date())
    })
  ]
};

Other packages similar to rollup-plugin-replace

Keywords

FAQs

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