path-pkg

1.1.1 • Public • Published

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'
    }]
  }
  ...
}

/path-pkg/

    Package Sidebar

    Install

    npm i path-pkg

    Weekly Downloads

    256

    Version

    1.1.1

    License

    ISC

    Last publish

    Collaborators

    • pwmckenna