Skip to content

JS development cycle is broken after dropwizard merge #1330

Closed

Description

@karussell

In order to develop JS code we did:

cd web
npm run watch

and then we were able to refresh the browser. Now the changes take effect only if we repackage the jar e.g. via

mvn clean install -DskipTests=true

It is possible to load assets directly from disc instead of looking inside the jar. I found this plugin

With a changed npm-watch task one can use it if the server was started from an IDE:
watchify src/main/resources/assets/js/main-template.js -o target/classes/assets/js/main.js --debug --verbose
but this is ugly as we don't want to force JS devs to mess around with IDEs.

Activity

  1. added this to the 0.11 milestone on Apr 9, 2018
  2. karussell commented on Apr 10, 2018

    @karussell
    MemberAuthor

    Using the linked plugin and

    bootstrap.addBundle(new FileAssetsBundle("web/src/main/resources/assets", "/maps/", "index.html"));

    works as intended with and without an IDE and without other changes.

    @michaz can we make this line configurable somehow and avoid as default (for production) to increase security?

    We could use another plugin: https://github.com/dropwizard-bundles/dropwizard-configurable-assets-bundle#getting-started

    But this makes us dependent on the security of this external plugin.

  3. karussell commented on Apr 10, 2018

    @karussell
    MemberAuthor

    I was able to make it working through a new application class:

    public class GraphHopperDebugApplication extends GraphHopperApplication {
        public static void main(String[] args) throws Exception {
            new GraphHopperDebugApplication().run(args);
        }
    
        @Override
        public void initialize(Bootstrap<GraphHopperServerConfiguration> bootstrap) {
            super.initialize(bootstrap);
            bootstrap.addBundle(new FileAssetsBundle("web/src/main/resources/assets", "/maps/", "index.html"));
        }
    }

    And called java -cp gh.jar com.graphhopper.http.GraphHopperDebugApplication server config.yml
    But is this the way to go? I would have thought I could just use a different command like server-debug but wasn't able to get it working as the initialize method only offer a configfactory somehow.

  4. changed the title [-]Usual JS development cycle is broken after dropwizard merge[/-] [+]JS development cycle is broken after dropwizard merge[/+] on Apr 10, 2018
  5. easbar commented on Apr 12, 2018

    @easbar
    Member

    I tried this but no matter what I did the assets were always picked up from the jar/classpath (although I verified that GraphHopperDebugApplication was running). I would have liked to check the FileAssetServlet debug logging as mentioned here, but then I did not manage to configure log4j with dropwizard :( ? It does not let me pass -Dlog4j.configurationFile via the command line and it seemingly did not pick up any log4j.xml files from the class path (I tried putting it in core/src/main/resources), either. I also did not find out where dropwizard picks up the logging configuration from (?).

  6. michaz commented on Apr 12, 2018

    @michaz
    Member

    (Could you perhaps contribute whatever you put into your configuration as an example, for config-example.yml, please?)

  7. 16 remaining items

  8. karussell commented on Apr 20, 2018

    @karussell
    MemberAuthor

    Oh, this was a stupid mistake and is now fixed: 4d95eb5

    @ammagamma would you try again if hot reloading works for you?
    @michaz I'll format all files according to new IntelliJ (see linked commit and also stumbled over it here) or will this break some of your branches?

  9. michaz commented on Apr 20, 2018

    @michaz
    Member

    @karussell Sure, go ahead!

  10. michaz commented on Apr 20, 2018

    @michaz
    Member

    Oh, this was a stupid mistake and is now fixed

    Now we are not including the webapp at all anymore in the non-debug-version.

  11. karussell commented on Apr 21, 2018

    @karussell
    MemberAuthor

    Now we are not including the webapp at all anymore in the non-debug-version.

    Bad. Maybe we should then use the configurable asset and include UI by default (to serve via classpath or disc) and offer a separate api action without this for stricter security.

  12. michaz commented on Apr 21, 2018

    @michaz
    Member

    Here we go. See config-example.yml. No separate class or command necessary. I don't have security concerns. I think this is done.

  13. karussell commented on Apr 21, 2018

    @karussell
    MemberAuthor

    Thanks!

  14. karussell commented on Apr 23, 2018

    @karussell
    MemberAuthor

    Can confirm that this works - have changed the script and docs accordingly.

  15. added a commit that references this issue on Apr 23, 2018
  16. easbar commented on Apr 27, 2018

    @easbar
    Member

    @ammagamma would you try again if hot reloading works for you?

    to be honest it does not, but I will try again...

  17. karussell commented on Apr 27, 2018

    @karussell
    MemberAuthor

    Tested it again and when editing the JS file in IntelliJ I didn't even need to save and just refreshed in the browser. Steps I did:

    • edit config.yml and uncomment the lines related to asset
    • latest commit on master
    • ./graphhopper.sh clean; ./graphhopper.sh web /home/peter/Downloads/berlin-latest.osm.pbf
    • (in a second terminal do:) cd web; npm run watch
  18. easbar commented on Apr 28, 2018

    @easbar
    Member

    Ok it works :) I think the overrides path in my config.yml was not correct relative to the working directory.

  19. karussell commented on Apr 28, 2018

    @karussell
    MemberAuthor

    Ah, ok. Maybe we should change it relative to the root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions