vaadin / vaadin/spring

Add documentation on how to configure copying of resources when Spring is used

Open
#269 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
186
Forks
98
PR merge metrics
No merged PRs in 30d

Description

@SomeoneToIgnore commented on Tue Jan 16 2018

@denis-anisimov commented on Fri Jan 12 2018

I'm using bakery app (latest commit is 93f120fab1c139100593f087c5ff0226a3521d3d ).

I've modified the pom.xml file via replacing a custom resources unpack goal ( "unpack-flow-component-renderer-html") and transpilation by flow-maven plugin:

<plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>flow-maven-plugin</artifactId>
                        <version>0.0.5</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>copy-production-files</goal>
                                    <goal>transpile-production-files</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

Note that :

  • you still need the copy task ( from appropriate directory) to src/main/webapp/frontend directory. The place which Spring boot uses to handle web resource.
  • you need to modify flow maven plugin to avoid dependency to Flow snapshot (and use appropriate flow release version ).

I use Spring boot run task (make sure that you use the appropriate paths to transpiled files).

In the result: application is loading ( there are not at least exceptions about inability to find HTML import resources in the context) but it fails because of babel-helpers.

There the an exception on the clien side :

Uncaught ReferenceError: babelHelpers is not defined
    at i (highstock.js:1)
    at Object.f.merge (highstock.js:1)
    at Object.f.seriesType (highstock.js:1)
    at highstock.js:1
    at highstock.js:1
    at highstock.js:1
    at highstock.js:1

It looks like babel-helpers is referenced from high charts but it's not available ( and most likely should not be available since they should be inlined only for es5 as I see from the BootstrapHandler.java).

It might be that I'm doing something wrong but anyway the configuration of the plugin is quite unclear especially in Spring case.
May be we need to do something to improve this for Spring somehow.


@pleku commented on Fri Jan 12 2018

In the result: application is loading ( there are not at least exceptions about inability to find HTML import resources in the context) but it fails because of babel-helpers.

For the babel helpers there is already https://github.com/vaadin/flow-maven-plugin/issues/31

you still need the copy task ( from appropriate directory) to src/main/webapp/frontend directory. The place which Spring boot uses to handle web resource.

If I understand correctly, we need to make sure the plugin works auto-of-the-box when it is used with Spring.


@denis-anisimov commented on Fri Jan 12 2018

For the babel helpers there is already #31

Good. Didn't know that. Then it should be fixed.

you still need the copy task ( from appropriate directory) to src/main/webapp/frontend directory. >>The place which Spring boot uses to handle web resource.

If I understand correctly, we need to make sure the plugin works auto-of-the-box when it is used with Spring.

I'm not sure whether it's feasible actually. One needs to copy transpiled files from "build" directory to sources so that Spring sees them as web resources.
This is done at the moment as a separate task in Bakery (there is a copy step).

It would be very good to avoid such copy since it's an overhead and you should know about this.
But how we can do this in reality: we should somehow detect Spring in the project and also we should somehow know which exactly folder is used in this project for web resources (Bakery uses src/main/webapp/ but I'm pretty sure it can be changed via configuration).


@Legioth commented on Mon Jan 15 2018

It would be very good to avoid such copy since it's an overhead

Does it really matter? From my understanding, the copying is only needed for production builds, so it's quite acceptable that they are not lightning fast.


@denis-anisimov commented on Mon Jan 15 2018

Does it really matter? From my understanding, the copying is only needed for production builds, so it's quite acceptable that they are not lightning fast.

The problem is the knowledge of this step. Not its speed.
I don't know which folder should I copy and I don't even know that I have to copy.
If we have a plugin then I expect that it does all boilerplate work for me. Otherwise why should I use it at all if I can do the same things using another ways?


@pleku commented on Mon Jan 15 2018

Acceptance Criteria

Add the instructions on what to change for flow-maven-plugin configuration for making a production build, when working with Spring apps to the following places:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with flow-documentation/spring/tutorial-spring-basic.asciidoc and the Making a production build tutorial referenced in the acceptance criteria, then inspect Skeleton-starter-flow-spring. Document the flow-maven-plugin production configuration and the required copy into src/main/webapp/frontend, with matching guidance in all three named places.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
build-system, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.