I faced a problem while using Google Closure Soy templates. When I change a template I need to run a script from command line to compile Soy template to JS file. Is there a service or something else to rebuild these templates automatically?
Also, as far as I know, "plovr" service is able to rebuild JS sources with closure compiler automatically. Is there a way to rebuild soy templates and put them to specified folder by plovr automatically?
Plovr will automatically compile Closure Templates (soy files) along with JavaScript sources.
If your project had the following file structure, you could use the plovr config file shown below.
/home/my/project
|-- build
|-- js
|-- myapp.js
|-- soy
|-- mytemplate.soy
{
"id": "myapp",
"inputs": [
"/home/my/project/js/myapp.js"
],
"paths": [
"/home/my/project/soy"
],
"mode": "ADVANCED",
"level": "VERBOSE",
"output-file": "/home/my/project/build/myapp.compiled.js"
}
During development, you would configure a <script> tag in your HTML file to automatically recompile your JavaScript and Closure Templates after launching the plovr server:
java -jar plovr.jar serve plovr_config.json
<!doctype html>
<html>
<head>
<title>My App</title>
</head>
<body>
<h1>My App</h1>
<script src="http://0.0.0.0:9810/compile?id=myapp"></script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With