@ryaninvents/plugin-bundle-zip-node

1.4.0 • Public • Published

@ryaninvents/plugin-bundle-zip-node

Plugin for @pika/pack to zip built files for Node.js

CircleCI build status View on npm GitHub repository License

Why would I want this?

This package creates a zip file containing your compiled source code. After the build step runs, the zip file will be available in ./pkg/dist-node.zip.

I built this package because I wanted to build an AWS Lambda function source zip using Pika Pack.

Installation

Use the package manager npm to install @ryaninvents/plugin-bundle-zip-node.

npm install --save-dev @ryaninvents/plugin-bundle-zip-node

Then, modify your @pika/pack configuration in your package.json to enable:

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node"]
    ]
  }
}

For more details on setting up Pack, refer to the @pika/pack repository. For details on configuring plugin-bundle-zip-node, keep reading.

Options

preserve

Default value: false

Preserve the package root -- that is, the zip file will contain everything in the Pika pkg directory. Note: By default, this will not include the package.json.

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node", {
        "preserve": true
      }]
    ]
  }
}

bundleName

Default value: "node"

Specify a name for the bundle. The bundle will be stored as dist-${bundleName}.zip.

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node", {
        "bundleName": "javascript"
      }]
    ]
  }
}

directory

Default value: "dist-node"

Choose a different directory to bundle. Note that this will have no effect on bundle name. Also if you have set preserve: true, then this option will have no effect.

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node", {
        "directory": "dist-web",
        "bundleName": "web"
      }]
    ]
  }
}

manifest

Default value: true when "preserve": true; false otherwise

Include the package.json in the bundle. Note that this will be the package.json as modified by any preceding Pika pipeline steps.

If you set "manifest": true while "preserve": false, you may end up with unexpected results. Proceed with caution.

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node", {
        "preserve": true,
        "manifest": true
      }]
    ]
  }
}

sources

Default value: ["**"]

Power-user option. Directly specify a set of files to use. Use negation to exclude files; for example, exclude test files using "!*.test.js".

{
  "@pika/pack": {
    "pipeline": [
      ["@pika/plugin-standard-pkg"],
      ["@pika/plugin-build-node"],
      ["@ryaninvents/plugin-bundle-zip-node", {
        "sources": [
          "*.js",
          "!*.test.js"
        ]
      }]
    ]
  }
}

epoch

Default value: true

When true, the zip file will always be created with the same timestamp. Set to false to generate correct timestamps.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @ryaninvents/plugin-bundle-zip-node

Weekly Downloads

0

Version

1.4.0

License

MIT

Unpacked Size

9.58 kB

Total Files

5

Last publish

Collaborators

  • ryaninvents