Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parcel-processor

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-processor

write asset files to a package directry given an entry point

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
2
Weekly downloads
 
Created
Source

parcel-processor

write asset files to a package directory given an entry point

build status

example

Given an entry point on process.argv[2], create a browserify bundle and write the inline assets to opts.dst:

var copier = require('parcel-processor');
var browserify = require('browserify');
var path = require('path');
var file = path.resolve(process.argv[2]);

copier(browserify(file), {
    keys: [ 'style' ],
    dst: __dirname + '/dst'
});

methods

var copier = require('parcel-processor')

var cp = copier(b, opts)

Given a browserify instance b and some options opts, copy asset files from the parcel-map output to the destination opts.dst.

The options are:

  • opts.dst - the destination root to start writing package files at
  • opts.keys - array of keys for parcel-map to read from the package.json
  • opts.defaults - object of default values passed directly through to parcel-map

The return value is an event emitter cp with some events documented below.

events

cp.on('bundle.css', function (file) {})

When the concatenated css bundle has been written, this event fires with the file path.

cp.on('bundle.js', function (file) {})

When the concatenated js bundle has been written, this event fires with the file path.

cp.on('package', function (pkg) {})

This event fires when a package is being written.

pkg has these properties:

  • pkg.isParcel - whether the package is a parcel
  • pkg.package - the package.json contents
  • pkg.assets - an array of assets paths declared in pkg
  • pkg.id - the package.json identifier from parcel-map
  • pkg.files - an object mapping the opts.keys types to arrays of matching file paths for each type
  • pkg.path - the path to the package root containing a package.json
  • pkg.dependencies - an array of dependency ids that pkg depends on
  • pkg.hash - the hash name used for the asset directory

Example pkg output:

{ package: 
   { view: 'view.html',
     main: 'main.js',
     style: '*.css',
     __dirname: '/home/substack/projects/parcel-processor/example/views/page1' },
  assets: [ '/home/substack/projects/parcel-processor/example/views/page1/x.css' ],
  id: '2814e2ae0d4b530be5c8adee15a7d5ce16246f96',
  files: { style: [ '/home/substack/projects/parcel-processor/example/views/page1/x.css' ] },
  path: '/home/substack/projects/parcel-processor/example/views/page1',
  dependencies: [],
  hash: '5c1f45e9747e602cfcda7c2b390b6779d11acb80' }

cp.on('map', function (map) {})

This event fires when the asset map from parcel-map is available.

cp.on('done', function () {})

When the package and all dependent packages are completely written, this event fires.

install

With npm do:

npm install parcel-processor

license

MIT

Keywords

FAQs

Package last updated on 02 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc