public final class DevModeHandler extends Object
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.
By default it keeps updated npm dependencies and node imports before running
webpack server
| Modifier and Type | Field and Description |
|---|---|
static String |
WEBPACK_SERVER
The local installation path of the webpack-dev-server node script.
|
| Modifier and Type | Method and Description |
|---|---|
static DevModeHandler |
getDevModeHandler()
Get the instantiated DevModeHandler.
|
String |
getFailedOutput()
Return webpack console output when a compilation error happened.
|
int |
getPort()
Get the listening port of the 'webpack-dev-server'.
|
boolean |
isDevModeRequest(HttpServletRequest request)
Returns true if it's a request that should be handled by webpack.
|
HttpURLConnection |
prepareConnection(String path,
String method)
Prepare a HTTP connection against webpack-dev-server.
|
void |
removeRunningDevServerPort()
Remove the running port from the vaadinContext and temporary file.
|
boolean |
reuseDevServer()
Whether the 'webpack-dev-server' should be reused on servlet reload.
|
boolean |
serveDevModeRequest(HttpServletRequest request,
HttpServletResponse response)
Serve a file by proxying to webpack.
|
static DevModeHandler |
start(DeploymentConfiguration configuration,
File npmFolder)
Start the dev mode handler if none has been started yet.
|
static DevModeHandler |
start(int runningPort,
DeploymentConfiguration configuration,
File npmFolder)
Start the dev mode handler if none has been started yet.
|
void |
stop()
Stop the webpack-dev-server.
|
public static final String WEBPACK_SERVER
public static DevModeHandler start(DeploymentConfiguration configuration, File npmFolder)
configuration - deployment configurationnpmFolder - folder with npm configuration filespublic static DevModeHandler start(int runningPort, DeploymentConfiguration configuration, File npmFolder)
runningPort - port on which Webpack is listening.configuration - deployment configurationnpmFolder - folder with npm configuration filespublic static DevModeHandler getDevModeHandler()
null if not startedpublic boolean isDevModeRequest(HttpServletRequest request)
request - the servlet requestpublic boolean serveDevModeRequest(HttpServletRequest request,
HttpServletResponse response)
throws IOException
Note: it considers the HttpServletRequest#getPathInfo that will
be the path passed to the 'webpack-dev-server' which is running in the
context root folder of the application.
request - the servlet requestresponse - the servlet responseIOException - in the case something went wrong like connection refusedpublic HttpURLConnection prepareConnection(String path, String method) throws IOException
path - the file to requestmethod - the http method to useIOException - on connection errorpublic String getFailedOutput()
public void removeRunningDevServerPort()
public int getPort()
public boolean reuseDevServer()
public void stop()
Copyright © 2020. All rights reserved.