Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SomeoneToIgnore opened this issue Jan 16, 2018 · 1 comment

Comments

@SomeoneToIgnore
Copy link
Contributor

@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:

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

No branches or pull requests

3 participants