npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

abspath-webpack-plugin

v0.0.1

Published

Custom absolute path(s) provider for node apps bundled with webpack

Downloads

7

Readme

Absolute paths for webpack

abspath-webpack-plugin is a custom absolute path(s) provider for your webpack builds.

It helps you get rid of relative paths in your requires and imports.

Installation

To install the latest stable version:

npm install --save-dev abspath-webpack-plugin

This assumes you are using npm as your package manager. The abspath-webpack-plugin requires webpack as peerDependency. Thus you are able to specify the required versions accurately.

Usage

Documentation: Using Plugins

Syntax / Config
new AbsolutePathProviderPlugin(newRegEx, absolutePath);

newRegEx is the regular expression to be matched in the required path and gets replaced with the absolutePath provided as the second argument.

You can also append path to the regex in your require statement. It automatically gets appended to the absolutePath.

Apply via webpack config

You need to use abspath-webpack-plugin with other plugins in your webpack configuration.

var webpack = require('webpack');
var AbsolutePathProviderPlugin = require('abspath-webpack-plugin');

module.exports = {
  plugins: [
    new AbsolutePathProviderPlugin(
      /* regex */: /* absolute path to some dir */
    )
  ]
}

Example

Let's see how can we use the plugin to simplify our require statements.

Here is your simple app structure, let's say.

app/
+-- _webpack.config.js
+-- scripts/
    +-- accounts/
        +-- signup/
            +-- app.js
+-- components/
    +-- modal/
        +-- index.js
        +-- modal.js
    +-- message/
        +-- index.js
        +-- message.js

Now you need to use your modal and message components in scripts/accounts/signup/app.js. The usual way would be

app.js (earlier)
var modal = require('./../../../components/modal');
var message = require('./../../../components/message');

That's not very efficient, right? Let's put abspath-webpack-plugin into play.

webpack.config.js
var path = require('path');
var webpack = require('webpack');
var AbsolutePathProviderPlugin = require('abspath-webpack-plugin');

module.exports = {
  plugins: [
    new AbsolutePathProviderPlugin(
      /^@components/: path.resolve('./components')
    )
  ]
}
app.js (after webpack config)
var modal = require('@components/modal');
var message = require('@components/message');

Or if you're using ES2015 syntax,

import modal from '@components/modal'
import message from '@components/message'

Contributing

We are open to, and grateful for, any contributions made by the community. You can contribute by:

  • Reporting a bug.
  • Suggesting a feature.
  • Opening an issue to discuss improvements, theory or implementation.

If you are opening a PR, please attach the relevant issue with it. If it doesn't exist, please create one before you open a PR.

License

MIT