Resolves aliases with Rollup

This module has moved and is now available at @rollup/plugin-alias. Please update your dependencies. This version is no longer maintained.
Last updated 9 months ago by lukastaegert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rollup-plugin-alias 
SYNC missed versions from official npm registry.


Define aliases when bundling packages with Rollup.

Build Status Dependency Status devDependency Status Coverage Status

Let's take a simple import as an example:

import something from '../../../something';


This probably doesn't look too bad on its own. But imagine this is not the only instance in your code base and after a refactor/restructuring this might fall over. With this plugin in place, you can alias ../../../something with something for readability. In case of a refactor only the alias would need to be changed instead of navigating through the code base and changing all imports.

import something from 'something';


When we write tests, we may want an easier way to access the local library we are testing or mocking libraries. We may also define aliases to counteract "require hell" and get rid of all those ../../../ imports we may have in the process.

For Webpack users: This is a plugin to mimic the resolve.alias functionality in Rollup.


$ npm install rollup-plugin-alias


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

export default {
  input: './src/index.js',
  plugins: [
      resolve: ['.jsx', '.js'], //optional, by default this will just look for .js files or folders
        {find:'something', replacement: '../../../something'}, //the initial example
        {find:'somelibrary-1.0.0', replacement: './mylocallibrary-1.5.0'}, //remap a library with a specific version
        {find:/^i18n\!(.*)/, replacement: '$1.js'}, //remove something in front of the import and append an extension (e.g. loaders, for files that were previously transpiled via the AMD module, to properly handle them in rollup as internals now)
        //for whatever reason, replace all .js extensions with .wasm
        {find:/^(.*)\.js$/, replacement: '$1.wasm'}

// or with object syntax
export default {
  input: './src/index.js',
  plugins: [
      resolve: ['.jsx', '.js'],
      entries: {
        something: '../../../something',
        'somelibrary-1.0.0': './mylocallibrary-1.5.0',

The order of the entries is important, in that the first rules are applied first.

You can use either simple Strings or Regular Expressions to search in a more distinct and complex manner (e.g. to do partial replacements via subpattern-matching, see aboves example).


MIT, see LICENSE for more information

Current Tags

  • 2.2.0                                ...           latest (9 months ago)

16 Versions

  • 2.2.0 [deprecated]           ...           9 months ago
  • 2.1.0 [deprecated]           ...           10 months ago
  • 2.0.1 [deprecated]           ...           10 months ago
  • 2.0.0 [deprecated]           ...           a year ago
  • 1.5.2 [deprecated]           ...           a year ago
  • 1.5.1 [deprecated]           ...           2 years ago
  • 1.5.0 [deprecated]           ...           2 years ago
  • 1.4.0 [deprecated]           ...           3 years ago
  • 1.3.1 [deprecated]           ...           3 years ago
  • 1.3.0 [deprecated]           ...           3 years ago
  • 1.2.1 [deprecated]           ...           3 years ago
  • 1.2.0 [deprecated]           ...           4 years ago
  • 1.1.0 [deprecated]           ...           4 years ago
  • 1.0.2 [deprecated]           ...           4 years ago
  • 1.0.1 [deprecated]           ...           4 years ago
  • 1.0.0 [deprecated]           ...           4 years ago
Today 461
This Week 461
This Month 674
Last Day 99
Last Week 2,171
Last Month 10,009
Dependencies (1)
Dev Dependencies (8)
Dependents (161)

Copyright 2014 - 2016 © |