Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vladimirmikulic/parcel-plugin-gas-imports
Parcel plugin that enables bundling of Google App Script HTML.
https://github.com/vladimirmikulic/parcel-plugin-gas-imports
bundle-adjustment google-apps-script parcel parcel-plugin scriptlets web
Last synced: 5 days ago
JSON representation
Parcel plugin that enables bundling of Google App Script HTML.
- Host: GitHub
- URL: https://github.com/vladimirmikulic/parcel-plugin-gas-imports
- Owner: VladimirMikulic
- License: mit
- Created: 2020-08-09T23:17:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T23:55:37.000Z (over 3 years ago)
- Last Synced: 2024-04-22T21:07:56.389Z (7 months ago)
- Topics: bundle-adjustment, google-apps-script, parcel, parcel-plugin, scriptlets, web
- Language: JavaScript
- Homepage:
- Size: 130 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# parcel-plugin-gas-imports
![Version](https://img.shields.io/npm/v/parcel-plugin-gas-imports)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)
[![Twitter: VladoDev](https://img.shields.io/twitter/follow/VladoDev.svg?style=social)](https://twitter.com/VladoDev)> đĨ Parcel plugin that enables bundling of Google App Script HTML.
_This is the plugin for Parcel v1. The plugin for the second version can be found [here](https://github.com/VladimirMikulic/parcel-reporter-gas-imports)._
## đ Introduction
If you've ever developed an add-on for Google's Office Suite with Google Apps Script,
then you'll know how inefficient it is to develop your add-on's UI.
This is because Google's Apps Script supports only .gs and .html files.
If you want to use CSS and JS, the only option is to create an HTML file and wrap
your CSS code inside `` tag or your JS inside `<script>` tag and include
it in your UI using [scriptlets](https://developers.google.com/apps-script/guides/html/best-practices#separate_html_css_and_javascript).This approach has serious flaws.
Parcel (nor any other modern JS bundler for that matter), doesn't recognize scriptlets `<?!= ?>`.
Because of this, it won't apply any code transformation to those files and won't bundle them.**Why is this approach bad?**
- đĢ CSS not prefixed (The UI breaks on some browsers)
- đĢ JS not transpiled (Usage of modern JS not possible)
- đĢ Code can't be split in modules
- đŖ Large file sizes (Code not minified)## :package: Installation
```sh
# Installs the plugin and saves it as a development dependency
npm i parcel-plugin-gas-imports -D
```## :cloud: Usage
The plugin allows you to include your JS and CSS just like you would normally do it in HTML:
```sh
# Example add-on UI files
src
âââ index.html
âââ style.css
âââ script.js
```**index.html**
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="style.css" />
</head><body>
<h1>Google Apps Script Sidebar</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>
```### đ Build
`parcel build src/index.html`
```sh
# Fully optimized project ready for deployment
dist
âââ index.html
âââ style.e308ff8e.css.html
âââ script.75da7f30.js.html
```> âšī¸ NOTE: If you want to prevent this plugin from running in certain cases you can set `PARCEL_PLUGIN_GAS_IMPORTS=false` environment variable.
## :sparkles: Run tests
The plugin uses [Jest](https://jestjs.io/) for running tests.
Jest will execute all `.test.js` files in the `test` folder.
```sh
npm test
```## :man: Author
**Vladimir Mikulic**
- Twitter: [@VladoDev](https://twitter.com/VladoDev)
- Github: [@VladimirMikulic](https://github.com/VladimirMikulic)
- LinkedIn: [@vladimirmikulic](https://www.linkedin.com/in/vladimir-mikulic/)## :handshake: Contributing
Contributions, issues and feature requests are welcome!
## :pencil: License
This project is licensed under [MIT](https://opensource.org/licenses/MIT) license.
## :man_astronaut: Show your support
Give a âī¸ if this project helped you!