Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shff/parcel-plugin-inliner
Parcel plugin to inline CSS and JS code in your HTML file.
https://github.com/shff/parcel-plugin-inliner
frontend inliner parcel parcel-bundler parcel-plugin
Last synced: 3 months ago
JSON representation
Parcel plugin to inline CSS and JS code in your HTML file.
- Host: GitHub
- URL: https://github.com/shff/parcel-plugin-inliner
- Owner: shff
- License: mit
- Created: 2018-07-16T19:16:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T09:13:07.000Z (almost 3 years ago)
- Last Synced: 2024-07-21T17:46:41.667Z (4 months ago)
- Topics: frontend, inliner, parcel, parcel-bundler, parcel-plugin
- Language: JavaScript
- Homepage: https://npmjs.com/package/parcel-plugin-inliner
- Size: 120 KB
- Stars: 70
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-parcel - Inliner - Inlines all your CSS, JS and images in a single HTML file. Great for small websites. (Plugins / Other)
README
# parcel-plugin-inliner
A Parcel plugin to inline CSS and JS code in your HTML file.
This plugin uses [PostHTML](https://www.npmjs.com/package/posthtml) and [posthtml-inline-assets](https://www.npmjs.com/package/posthtml-inline-assets) to inline your HTML files.
## IMPORTANT NOTICE:
Due to a change in Parcel 2.0 API, plugins whose package name start with `parcel-plugin-` don't work on it. This plugin needs Parcel 1.x.
If you want inlining in Parcel 2.0, check their documentation: [Inline script and style tags :: v2.parceljs.org](https://v2.parceljs.org/languages/html/#inline-script-and-style-tags).
## Usage
Just install the plugin as a dependency using yarn or npm and build normally with Parcel. There are no configuration options.
## Installation
```
yarn add parcel-plugin-inliner
```or
```
npm install parcel-plugin-inliner
```## Caveats
This library only inlines files that are referenced directly in your entry point HTML file. It doesn't inline dependencies referenced inside JS and CSS files. It also doesn't inline files loaded asyncronously using Javascript. It doesn't affect code-splitting.
It only inlines the entry point of your app, and only works with HTML files.
It does not delete the JS and CSS files.
## Example
#### Original HTML file:
```
Project
```
#### Resulting HTML file:
```
Project html{-webkit-text-size-adjust:100%;line-height:1.15}body{margin:0} ... .h-100{height:100%} parcelRequire=function(e,t,n,r){function o(n,r){ ... },{preact:"WHr8",tachyons:"kuxM"}]},{},["WoLR"]);
```CSS and JS sections were shortened for example.
## License
```
MIT License
Copyright (c) 2018 Silvio Henrique Ferreira
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```