title | order | layout |
---|---|---|
Advanced Production Mode Topics |
5 |
page |
This is an upcoming feature of a Vaadin Platform 14.x minor release, probably during 2020. You can follow & comment on vaadin/flow#5537 if this is important for you.
Here we describe the maven plugin goals and their usage.
This goal validates whether the node
and npm
tools are installed and not too old (node
version 10 or later and npm
version 5.6 or later), and also installs them automatically to the .vaadin
folder in the user’s home directory if they are missing.
If they are installed globally but too old, there will be an error message suggesting to install newer versions instead.
Node.js is needed to run npm for installing frontend dependencies and webpack which bundles the frontend files served to client.
Note
|
Automatic installation of Node.js and npm is available since Vaadin 14.2. Older platform versions in the 14 series requires manual installation, either globally or in the project directory using a Maven plugin. |
In addition, it visits all resources used by the application and copies them under node_modules
folder so they are available when webpack
builds the frontend. It also creates or updates package.json
, webpack.config.json
and webpack.generated.json
files.
-
includes (default:
**/*.js,**/*.css
): Comma separated wildcards for files and directories that should be copied. Default is only .js and .css files. -
npmFolder (default:
${project.basedir}
): The folder wherepackage.json
file is located. Default is project root folder. -
webpackTemplate (default:
webpack.config.js
): Copy thewebapp.config.js
from the specified URL if missing. Default is the template provided by this plugin. Set it to empty string to disable the feature. -
webpackGeneratedTemplate (default:
webpack.generated.js
): Copy thewebapp.config.js
from the specified URL if missing. Default is the template provided by this plugin. Set it to empty string to disable the feature. -
generatedFolder (default:
${project.build.directory}/frontend/
): The folder where Flow will put generated files that will be used by Webpack. -
require.home.node (default:
false
): Available since Vaadin 14.2. If set totrue
, always prefer Node.js automatically downloaded and installed into the.vaadin
directory in the user’s home.
This goal builds the frontend bundle. This is a complex process involving several steps:
-
update
package.json
with all@NpmPackage
annotation values found in the classpath and automatically install these dependencies. -
update the JavaScript files containing code for importing everything used in the application. These files are generated in the
target/frontend
folder, and will be used as entry point of the application. -
create
webpack.config.js
if not found, or updates it in case some project parameters have changed. -
generate JavaScript bundles, chunks and transpile to ES5 using
webpack
server. Target folder in case ofwar
packaging istarget/${artifactId}-${version}/build
and in case ofjar
packaging istarget/classes/META-INF/resources/build
.
-
npmFolder (default:
${project.basedir}
: The folder wherepackage.json
file is located. Default is project root folder. -
generatedFolder (default:
${project.build.directory}/frontend/
): The folder where Flow will put generated files that will be used by Webpack. -
frontendDirectory (default:
${project.basedir}/frontend
): A directory with project’s frontend source files. -
generateBundle (default:
true
): Whether to generate a bundle from the project frontend sources or not. -
runNpmInstall (default:
true
): Whether to runpnpm install
(ornpm install
, depending on pnpmEnable parameter value) after updating dependencies. -
generateEmbeddableWebComponents (default:
true
): Whether to generate embeddable web components from WebComponentExporter inheritors. -
optimizeBundle (default:
true
): Whether to include only frontend resources used from application entry points (the default) or to include all resources found on the class path. Should normally be left to the default, but a value offalse
can be useful for faster production builds or debugging discrepancies between development and production mode. This configuration is available only in Vaadin Platform 14.1 and newer. -
pnpmEnable (default:
false
): Whether to use the pnpm or npm tool to handle frontend resources. By default npm is used. This configuration is available only in Vaadin 14.2 and newer.
One likely cause of this problem is that the build-frontend
of the flow-maven-plugin
was not executed, either because the plugin is missing from the pom.xml
or it is missing configuration.
To fix this, add the flow-maven-plugin
to your maven build
block (make sure it is visible in your production mode profile), and enable the build-frontend
goal.