com.vaadin.base.devserver.
Class WebpackHandler
- java.lang.Object
-
- com.vaadin.base.devserver.AbstractDevServerRunner
-
- com.vaadin.base.devserver.WebpackHandler
-
All Implemented Interfaces:
public final class WebpackHandler extends AbstractDevServerRunner
Runs a webpack dev server and provides files handles getting resources from
webpack-dev-server
.This class is meant to be used during developing time. For a production mode site
webpack
generates the static bundles that will be served directly from the servlet (using a default servlet if such exists) or through a stand alone static file server.For internal use only. May be renamed or removed in a future release.
Since:
2.0
See Also:
-
-
Field Summary
Fields Modifier and Type Field Description static String
WEBPACK_SERVER
The local installation path of the webpack-dev-server node script.
-
Constructor Summary
Constructors Constructor Description WebpackHandler(Lookup lookup, int runningPort, File npmFolder, CompletableFuture<Void> waitFor)
Creates and starts the dev mode handler if none has been started yet.
-
Method Summary
All Methods Modifier and Type Method Description protected File
getServerBinary()
Gets the binary that starts the dev server.
protected File
getServerConfig()
Gets the main configuration file for the dev server.
protected Pattern
getServerFailurePattern()
Gets a pattern to match with the output to determine that the server has failed to start.
protected String
getServerName()
Gets the name of the dev server for outputting to the user and statistics.
protected List<String>
getServerStartupCommand(FrontendTools tools)
Gets the commands to run to start the dev server.
protected Pattern
getServerSuccessPattern()
Gets a pattern to match with the output to determine that the server has started successfully.
protected void
onDevServerCompilation(DevServerOutputTracker.Result result)
Called whenever the dev server output matche the success or failure pattern.
protected void
updateServerStartupEnvironment(FrontendTools frontendTools, Map<String,String> environment)
Defines the environment variables to use when starting the dev server.
-
Methods inherited from class com.vaadin.base.devserver.AbstractDevServerRunner
checkConnection, doStartDevServer, getApplicationConfiguration, getFailedOutput, getPort, getProjectRoot, getWatchDog, handleRequest, prepareConnection, serveDevModeRequest, stop, triggerLiveReload, validateFiles, waitForDevServer, writeStream
-
-
-
-
Field Detail
-
WEBPACK_SERVER
public static final String WEBPACK_SERVER
The local installation path of the webpack-dev-server node script.
See Also:
-
-
Constructor Detail
-
WebpackHandler
public WebpackHandler(Lookup lookup, int runningPort, File npmFolder, CompletableFuture<Void> waitFor)
Creates and starts the dev mode handler if none has been started yet.
Parameters:
lookup
- the provided lookup to get required datarunningPort
- a port on which webpack is already running or 0 to start a new processnpmFolder
- folder with npm configuration fileswaitFor
- a completable future whose execution result needs to be available to start the dev server
-
-
Method Detail
-
onDevServerCompilation
protected void onDevServerCompilation(DevServerOutputTracker.Result result)
Description copied from class:
AbstractDevServerRunner
Called whenever the dev server output matche the success or failure pattern.
Overrides:
-
getServerStartupCommand
protected List<String> getServerStartupCommand(FrontendTools tools)
Description copied from class:
AbstractDevServerRunner
Gets the commands to run to start the dev server.
Specified by:
getServerStartupCommand
in classAbstractDevServerRunner
Parameters:
tools
- the frontend tools object
-
updateServerStartupEnvironment
protected void updateServerStartupEnvironment(FrontendTools frontendTools, Map<String,String> environment)
Description copied from class:
AbstractDevServerRunner
Defines the environment variables to use when starting the dev server.
Overrides:
updateServerStartupEnvironment
in classAbstractDevServerRunner
Parameters:
frontendTools
- frontend tools metadataenvironment
- the environment variables to use
-
getServerName
protected String getServerName()
Description copied from class:
AbstractDevServerRunner
Gets the name of the dev server for outputting to the user and statistics.
Specified by:
getServerName
in classAbstractDevServerRunner
-
getServerBinary
protected File getServerBinary()
Description copied from class:
AbstractDevServerRunner
Gets the binary that starts the dev server.
Specified by:
getServerBinary
in classAbstractDevServerRunner
-
getServerConfig
protected File getServerConfig()
Description copied from class:
AbstractDevServerRunner
Gets the main configuration file for the dev server.
Specified by:
getServerConfig
in classAbstractDevServerRunner
-
getServerSuccessPattern
protected Pattern getServerSuccessPattern()
Description copied from class:
AbstractDevServerRunner
Gets a pattern to match with the output to determine that the server has started successfully.
Specified by:
-
getServerFailurePattern
protected Pattern getServerFailurePattern()
Description copied from class:
AbstractDevServerRunner
Gets a pattern to match with the output to determine that the server has failed to start.
Specified by:
-
-