I have a JavaScript file that's a generated parser (let's call it MyParser
), which I am using in an add-on for Google Forms.
It needs to be used in the client side's Sidebar.html
where I'm including it with HtmlService.createHtmlOutputFromFile('MyParser.js').getContent();
, which means it must be an .html
file as far as I understand. Then it must be used on the server side where I have it in a file MyParser.js.gs
.
With my current solution, it's duplicated in my file structure:
Code.gs
MyParser.js.gs
MyParser.js.html
Sidebar.html
Is there a way I can make this work without having two files? Edit: As I understand it, libraries are only for the server side.
If not, any hints to making the updating of the two files more robust (currently it's manual copy/paste)?
Edit: According to the best practices, one must wrap the JavaScript inside a <script>
tag inside the .html
file:
Notice that the included files contain
<style>
and<script>
tags because they're HTML snippets and not pure .css or .js files.
So it seems it's not easy to have just one file.