1.1.0 • Published 2 years ago

parcel-reporter-mkpdf v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

npm

parcel-reporter-mkpdf

šŸ“¦ Plugin for Parcel web build tool:

Each time parcel builds an HTML (either in serve/watch or production mode), this plugin will save it as a PDF. The exported PDF will look the same as if you had used the Print functionality from Chrome.

Key features:

  • šŸ’« Iterative development: your PDF is generated every time parcel finishes an HTML built.
  • šŸŽØ Style the PDFs with your CSS/Less/Sass.
  • šŸš€ Fast "printing" of the PDFs thanks to internal caching. Your HTML linked external files (e.g. .js/.css) will be fetched only once.

Install package

Using npm:

npm install parcel-reporter-mkpdf --save-dev

Analogously, using yarn:

yarn add parcel-reporter-mkpdf --dev

How to use

To hook this plugin to parcel's builds, add this plugin name to the field reporters in your .parcelrc(https://parceljs.org/features/plugins/#.parcelrc) configuration; example:

{
  "extends": "@parcel/config-default",
  "reporters": [
    "...",
    "parcel-reporter-mkpdf"
  ]
}

As an alternative, use the --reporter option in parcel's CLI; example:

npx parcel serve --reporter parcel-reporter-mkpdf

That's all! From then on, each time parcel builds an HTML (e.g., dist/someFilename.html), the PDF will be generated in the same folder, with same filename but with changed file extension (i.e., dist/someFilename.pdf).

Coding

Internally, the PDF is "printed" with Chromium as a headless browser. The browser is controlled with Google's puppeteer.

  • The key functionality using puppeteer is in mkpdf.ts
  • The parcel plugin wrapper code is in index.ts
1.0.2

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.1-wip3

2 years ago

1.0.1-wip2

2 years ago

1.0.1-wip

2 years ago

1.0.0

2 years ago

1.0.0-wip

2 years ago