You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update articles for production build change (#4650)
* docs: update articles for production build change
Removed production profile from articles that use example apps that build or will build production package without any production profile.
Part of vaadin/flow#22464
* Update quarkus.adoc
* Update getting-started.adoc
---------
Co-authored-by: Mikhail Shabarov <[email protected]>
@@ -57,10 +64,62 @@ By default, Vaadin uses `npm install` to install frontend packages. This can be
57
64
58
65
When set, Vaadin interrupts package installation if it spots any mismatch between package versions in the [filename]`package.json` and the lock file. It'll then recommend re-running `npm install`. This makes production builds in the CI pipelines reproducible, enabling you to identify problems in advance.
59
66
60
-
61
67
== Enabling Production Builds
62
68
63
-
The production build command works out-of-the-box for Vaadin starter projects. It'll work with projects that are generated with `https://start.vaadin.com`. The starter projects come with the necessary Maven configuration. If you've manually created your project's [filename]`pom.xml` file, add the following Maven profile to enable production builds:
69
+
The production build command works out-of-the-box for Vaadin starter projects. It'll work with projects that are generated with `https://start.vaadin.com`. The starter projects come with the necessary Maven configuration.
70
+
71
+
If you've manually created your project's [filename]`pom.xml` file, add the following `vaadin-maven-plugin` to enable production builds when using Spring Boot:
72
+
73
+
.`pom.xml`
74
+
[source,xml]
75
+
----
76
+
<!--
77
+
.. configuration depending on environment ..
78
+
-->
79
+
80
+
<build>
81
+
<plugins>
82
+
<plugin>
83
+
<groupId>com.vaadin</groupId>
84
+
<artifactId>vaadin-maven-plugin</artifactId>
85
+
<version>${project.version}</version>
86
+
<executions>
87
+
<execution>
88
+
<goals>
89
+
<goal>prepare-frontend</goal>
90
+
</goals>
91
+
</execution>
92
+
<execution>
93
+
<id>package-for-production</id>
94
+
<goals>
95
+
<goal>build-frontend</goal>
96
+
</goals>
97
+
<phase>prepare-package</phase>
98
+
</execution>
99
+
</executions>
100
+
<configuration>
101
+
<!-- To always force an optimized production bundle build set this configuration to 'true' -->
102
+
<!-- To possibly use the pre-compiled production bundle remove or set to 'false' -->
103
+
<forceProductionBuild>true</forceProductionBuild>
104
+
<!-- To have reproducible build by running 'npm ci' -->
105
+
<ciBuild>true</ciBuild>
106
+
</configuration>
107
+
</plugin>
108
+
<!--
109
+
.. more plugins ..
110
+
-->
111
+
</plugins>
112
+
</build>
113
+
<!--
114
+
.. more configuration ..
115
+
-->
116
+
----
117
+
118
+
The content depends on the environment in which your application is running, but all variations call the Maven goal `vaadin:build-frontend`. The Maven goal `vaadin:prepare-frontend` is also required. Once the `vaadin:build-frontend` goal targeting `prepare-package` phase is added, you can call the production build command.
119
+
120
+
If you don't have the `build-frontend` goal in your [filename]`pom.xml` file, get a project base for Spring Boot projects from `https://start.vaadin.com`. Then copy the `vaadin-maven-plugin` plugin from the downloaded [filename]`pom.xml` file.
121
+
122
+
For other applications, e.g., Jakarta EE or plain Java, and for better backwards compatibility, add the following Maven profile to enable production builds and get a project base from `https://vaadin.com/hello-world-starters`:
64
123
65
124
.`pom.xml`
66
125
[source,xml]
@@ -106,12 +165,6 @@ The production build command works out-of-the-box for Vaadin starter projects. I
106
165
</profiles>
107
166
----
108
167
109
-
The content of the profile depends on the environment in which your application is running, but all variations call the Maven goal `vaadin:build-frontend`. The Maven goal `vaadin:prepare-frontend` is also required, but that's often declared already in the development build. Once the Maven profile is added, you can call the production build command.
110
-
111
-
If you don't have the production Maven profile in your [filename]`pom.xml` file, get a project base: for Spring Boot projects, get it from `https://start.vaadin.com`; for other stacks (e.g., Jakarta EE or plain Java) from `https://vaadin.com/hello-world-starters`. Then copy the production profile from the downloaded [filename]`pom.xml` file.
112
-
113
-
Having the production build as a separate Maven profile is recommended to avoid unexpected problems due to production settings during development.
114
-
115
168
.Building for 64-bit
116
169
[NOTE]
117
170
If you're using a 64-bit operating system, be sure to use a 64-bit JDK installation, as well.
@@ -146,6 +199,23 @@ The Vite server integration and live reload features -- which are available only
146
199
</profiles>
147
200
----
148
201
202
+
Or when building Spring Boot 4 application, add `vaadin-dev` dependency as a `optional` scope in project `<dependencies>`. Spring Boot 4 `spring-boot-maven-plugin` automatically excludes optional dependencies from the final build:
203
+
204
+
.`pom.xml`
205
+
[source,xml]
206
+
----
207
+
<dependencies>
208
+
...
209
+
<dependency>
210
+
<groupId>com.vaadin</groupId>
211
+
<artifactId>vaadin-dev</artifactId>
212
+
<optional>true</optional>
213
+
</dependency>
214
+
...
215
+
</dependencies>
216
+
----
217
+
218
+
149
219
This results in less code and fewer dependency libraries being bundled in the production application.
Copy file name to clipboardExpand all lines: articles/flow/testing/selenium.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,7 +156,7 @@ If you added your Selenium tests to a project that was generated from https://st
156
156
157
157
[source,terminal]
158
158
----
159
-
mvn verify -Pit,production
159
+
mvn verify -Pit
160
160
----
161
161
162
162
This runs the tests in the `it` profile, which starts the Spring Boot server before the tests are run -- and stops it afterwards. If you're running the test this way, your test classes must end with `IT`.
Copy file name to clipboardExpand all lines: articles/getting-started/build.adoc
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,26 +14,26 @@ Up to this point, the walking skeleton has been <<run#,running in development mo
14
14
15
15
== Make a Production Build
16
16
17
-
In the walking skeleton, you use the Vaadin Maven plugin to make a production build. You do this by activating the `production` profile, like this:
17
+
In the walking skeleton, you use the Vaadin Maven plugin to make a production build. You do this by activating the `package` goal, like this:
18
18
19
19
[.example]
20
20
--
21
21
[source,bash,subs="+attributes"]
22
22
----
23
23
<source-info group="macOS / Linux"></source-info>
24
-
./mvnw clean package -Pproduction
24
+
./mvnw clean package
25
25
----
26
26
27
27
[source,powershell,subs="+attributes"]
28
28
----
29
29
<source-info group="Windows"></source-info>
30
-
mvnw clean package -Pproduction
30
+
mvnw clean package
31
31
----
32
32
--
33
33
34
34
Once the build has finished, check the `target` directory. If your skeleton was named `my-application`, you should find a file called `my-application-1.0-SNAPSHOT.jar`.
35
35
36
-
The `production` profile not only builds the frontend, but also excludes the development server bundle since it contains features that aren't used in production.
36
+
The `package` goal not only builds the frontend, but also excludes the development server bundle since it contains features that aren't used in production.
37
37
38
38
39
39
== Build a Docker Image
@@ -107,7 +107,7 @@ RUN --mount=type=cache,target=/root/.m2 \
0 commit comments