path-pkg

Get package.json info for the package the path is in.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
path-pkg
001.1.16 years ago6 years agoMinified + gzip package size for path-pkg in KB

Readme

path-pkg
Get package.json info for the package the path is in.

Install

npm install path-pkg

Usage

Babel
var pathPkg = require('path-pkg');
require('babel-register')({
  only: function (filename) {
      return pathPkg(filename).author === 'Patrick Williams';
  }
});
Webpack 1.x.x
{
  ...
  module: {
    loaders: [{
      test: function (filename) {
        // Uses the babel loader for both this app's code, but also any npm
        // dependencies that you wrote.
        return pathPkg(filename).author === 'Patrick Williams' && new RegExp(/\.js$/).test(filename);
      },
      loader: 'babel'
    }]
  }
  ...
}
Webpack 2.x.x
{
  ...
  module: {
    rules: [{
      test: {
        and: [filename => pathPkg(filename).author === 'Patrick Williams', /\.jsx?$/]
      },
      use: 'babel-loader'
    }]
  }
  ...
}