Frage

I am trying to compile my JavaScript files using Plovr as defined in the config file below:

{
  "id": "hello_demo",
  "paths": ".",  
  "closure-library": "closure-library/closure/goog/",
  "mode": "ADVANCED",
  "level": "DEFAULT",
  "pretty-print": true, 
  "externs": ["prototype.js"],
  "modules": {
    "core_scripts": {
      "inputs": "core_scripts.js",
      "deps": []
    },
    "add_new_item": {
      "inputs": "add_new_item.js",
      "deps": "core_scripts"
    }
  },
  "module-output-path": "build/module_%s.js"
}

I start the Plovr server using the command below:

java -jar c:/wf/my_project/plovr/plovr.jar serve c:/wf/my_project/js/plovr-config.js

I then go to http://localhost:9810/compile?id=hello_demo in the web browser and once it's finished compiling it shows me the compiled code of "core_scripts.js" only

I expect the compiler to have created two compiled JavaScript files in "c:/wf/my_project/js/build/" but there is nothing.

Am I missing something?

Thank you for your help in advance.

War es hilfreich?

Lösung 2

You are using the "serve" command of plovr, which just starts the server (and compiles it on the server without generating static files). You want to run the "build" command (with the same options) to generate the files on your local server, like so:

java -jar c:/wf/my_project/plovr/plovr.jar build c:/wf/my_project/js/plovr-config.js

Andere Tipps

At http://www.klokantech.com/ we prepared a set of examples for the development with Plovr and Closure Library for newbies. See:

https://github.com/klokan/closure-library-plovr-hello-world-skeletons

There are a helloworld, basic app using Google Maps API V3, a demo with Closure Templates (soy), an OpenLayers app, etc.

I am not sure if you really need to compile modules - especially if you are new to Plovr and Closure. The idea of Closure Tools is that normally the complete code is all compiled into a single .js file - this is the way how the Closure Compiler Advanced minimization runs the best. Read my blog post:

http://blog.klokantech.com/2010/12/closure-compiler-for-openlayers-3x.html

Anyway, the skeleton example code mentioned above also shows how to work with modules in Plovr, eg. dynamically loadable extension of complex JavaScript code - think of a Gmail-like single-page application (SPA) where different parts of the interface are loading additional functionality (such as Settings dialog, Composer functionality for editor, etc). It is in the code as under modules-api and modules in https://github.com/klokan/closure-library-plovr-hello-world-skeletons.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top