rollup-plugin-replace

WebJar for rollup-plugin-replace

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

rollup-plugin-replace
Last Version

Last Version

2.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

rollup-plugin-replace
WebJar for rollup-plugin-replace
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/rollup/rollup-plugin-replace

Download rollup-plugin-replace

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/rollup-plugin-replace/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>rollup-plugin-replace</artifactId>
    <version>2.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/rollup-plugin-replace/
implementation 'org.webjars.npm:rollup-plugin-replace:2.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/rollup-plugin-replace/
implementation ("org.webjars.npm:rollup-plugin-replace:2.2.0")
'org.webjars.npm:rollup-plugin-replace:jar:2.2.0'
<dependency org="org.webjars.npm" name="rollup-plugin-replace" rev="2.2.0">
  <artifact name="rollup-plugin-replace" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='rollup-plugin-replace', version='2.2.0')
)
libraryDependencies += "org.webjars.npm" % "rollup-plugin-replace" % "2.2.0"
[org.webjars.npm/rollup-plugin-replace "2.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : magic-string jar [0.25.2,0.26)
org.webjars.npm : rollup-pluginutils jar [2.6.0,3)

Project Modules

There are no modules declared in this project.

Moved

This module has moved and is now available at @rollup/plugin-replace. Please update your dependencies. This repository is no longer maintained.

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 occurrence of `<@foo@>` instead of every
  // occurrence 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')
  }
}

Word boundaries

By default, values will only match if they are surrounded by word boundaries — i.e. with options like this...

{
	changed: 'replaced';
}

...and code like this...

console.log('changed');
console.log('unchanged');

...the result will be this:

console.log('replaced');
console.log('unchanged');

If that's not what you want, specify empty strings as delimiters:

{
  changed: 'replaced',
  delimiters: ['', '']
}

License

MIT

org.webjars.npm

Rollup

Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application.

Versions

Version
2.2.0