-
Couldn't load subscription status.
- Fork 213
docs: update articles for production build change #4650
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,14 @@ order: 10 | |
|
|
||
| = Production Build | ||
|
|
||
| To create a production build, run the following from the command-line: | ||
| To create a production build, run the following from the command-line for application using Spring Boot: | ||
|
|
||
| [source,terminal] | ||
| ---- | ||
| mvn clean package | ||
| ---- | ||
|
|
||
| For other applications, e.g., Jakarta EE or plain Java, and for better backwards compatibility, run same with a production profile: | ||
|
|
||
| [source,terminal] | ||
| ---- | ||
|
|
@@ -37,7 +44,7 @@ If needed, you can force the creation of an optimized production bundle by execu | |
|
|
||
| [source,terminal] | ||
| ---- | ||
| mvn clean package -Pproduction -Dvaadin.force.production.build=true | ||
| mvn clean package -Dvaadin.force.production.build=true | ||
| ---- | ||
|
|
||
| [NOTE] | ||
|
|
@@ -57,10 +64,62 @@ By default, Vaadin uses `npm install` to install frontend packages. This can be | |
|
|
||
| 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. | ||
|
|
||
|
|
||
| == Enabling Production Builds | ||
|
|
||
| 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: | ||
| 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 `vaadin-maven-plugin` to enable production builds when using Spring Boot: | ||
|
|
||
| .`pom.xml` | ||
| [source,xml] | ||
| ---- | ||
| <!-- | ||
| .. configuration depending on environment .. | ||
| --> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>com.vaadin</groupId> | ||
| <artifactId>vaadin-maven-plugin</artifactId> | ||
| <version>${project.version}</version> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>prepare-frontend</goal> | ||
| </goals> | ||
| </execution> | ||
| <execution> | ||
| <id>package-for-production</id> | ||
| <goals> | ||
| <goal>build-frontend</goal> | ||
| </goals> | ||
| <phase>prepare-package</phase> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <!-- To always force an optimized production bundle build set this configuration to 'true' --> | ||
| <!-- To possibly use the pre-compiled production bundle remove or set to 'false' --> | ||
| <forceProductionBuild>true</forceProductionBuild> | ||
| <!-- To have reproducible build by running 'npm ci' --> | ||
| <ciBuild>true</ciBuild> | ||
| </configuration> | ||
| </plugin> | ||
| <!-- | ||
| .. more plugins .. | ||
| --> | ||
| </plugins> | ||
| </build> | ||
| <!-- | ||
| .. more configuration .. | ||
| --> | ||
| ---- | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| 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`: | ||
|
|
||
| .`pom.xml` | ||
| [source,xml] | ||
|
|
@@ -106,12 +165,6 @@ The production build command works out-of-the-box for Vaadin starter projects. I | |
| </profiles> | ||
| ---- | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| Having the production build as a separate Maven profile is recommended to avoid unexpected problems due to production settings during development. | ||
|
|
||
| .Building for 64-bit | ||
| [NOTE] | ||
| 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 | |
| </profiles> | ||
| ---- | ||
|
|
||
| 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: | ||
|
|
||
| .`pom.xml` | ||
| [source,xml] | ||
| ---- | ||
| <dependencies> | ||
| ... | ||
| <dependency> | ||
| <groupId>com.vaadin</groupId> | ||
| <artifactId>vaadin-dev</artifactId> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| ... | ||
| </dependencies> | ||
| ---- | ||
|
|
||
|
|
||
|
Comment on lines
+202
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move this snippet to up (before a snippet with profile) so as to make it a primary recommended way for spring apps. |
||
| This results in less code and fewer dependency libraries being bundled in the production application. | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be easier to read if this can give a link to the fragment where the production profile is defined.