Package com.vaadin.base.devserver
Class WebpackHandler
- java.lang.Object
-
- com.vaadin.base.devserver.AbstractDevServerRunner
-
- com.vaadin.base.devserver.WebpackHandler
-
- All Implemented Interfaces:
DevModeHandler,RequestHandler,Serializable
public final class WebpackHandler extends AbstractDevServerRunner
Runs a webpack dev server and provides files handles getting resources fromwebpack-dev-server.This class is meant to be used during developing time. For a production mode site
webpackgenerates 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringWEBPACK_SERVERThe 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 Instance Methods Concrete Methods Modifier and Type Method Description protected FilegetServerBinary()Gets the binary that starts the dev server.protected FilegetServerConfig()Gets the main configuration file for the dev server.protected PatterngetServerFailurePattern()Gets a pattern to match with the output to determine that the server has failed to start.protected StringgetServerName()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 PatterngetServerSuccessPattern()Gets a pattern to match with the output to determine that the server has started successfully.protected voidonDevServerCompilation(DevServerOutputTracker.Result result)Called whenever the dev server output matche the success or failure pattern.protected voidupdateServerStartupEnvironment(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:
- Constant Field Values
-
-
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:AbstractDevServerRunnerCalled whenever the dev server output matche the success or failure pattern.- Overrides:
onDevServerCompilationin classAbstractDevServerRunner
-
getServerStartupCommand
protected List<String> getServerStartupCommand(FrontendTools tools)
Description copied from class:AbstractDevServerRunnerGets the commands to run to start the dev server.- Specified by:
getServerStartupCommandin classAbstractDevServerRunner- Parameters:
tools- the frontend tools object
-
updateServerStartupEnvironment
protected void updateServerStartupEnvironment(FrontendTools frontendTools, Map<String,String> environment)
Description copied from class:AbstractDevServerRunnerDefines the environment variables to use when starting the dev server.- Overrides:
updateServerStartupEnvironmentin classAbstractDevServerRunner- Parameters:
frontendTools- frontend tools metadataenvironment- the environment variables to use
-
getServerName
protected String getServerName()
Description copied from class:AbstractDevServerRunnerGets the name of the dev server for outputting to the user and statistics.- Specified by:
getServerNamein classAbstractDevServerRunner
-
getServerBinary
protected File getServerBinary()
Description copied from class:AbstractDevServerRunnerGets the binary that starts the dev server.- Specified by:
getServerBinaryin classAbstractDevServerRunner
-
getServerConfig
protected File getServerConfig()
Description copied from class:AbstractDevServerRunnerGets the main configuration file for the dev server.- Specified by:
getServerConfigin classAbstractDevServerRunner
-
getServerSuccessPattern
protected Pattern getServerSuccessPattern()
Description copied from class:AbstractDevServerRunnerGets a pattern to match with the output to determine that the server has started successfully.- Specified by:
getServerSuccessPatternin classAbstractDevServerRunner
-
getServerFailurePattern
protected Pattern getServerFailurePattern()
Description copied from class:AbstractDevServerRunnerGets a pattern to match with the output to determine that the server has failed to start.- Specified by:
getServerFailurePatternin classAbstractDevServerRunner
-
-