@@ -123,10 +123,25 @@ if (config.mode === "production") {{
123123 process.exit(1);
124124}}
125125
126- serve({{}}, {{
127- config,
128- hot: true,
126+ const webpack = require('webpack');
127+ const WebpackDevServer = require('webpack-dev-server');
128+ const port = 8080;
129+
130+ var options = require(path.resolve("{dev_server_options}"));
131+ options.publicPath = config.output.publicPath;
132+
133+ const server = new WebpackDevServer(webpack(config), options);
134+
135+ server.listen(port, 'localhost', function (err) {{
136+ if (err) {{
137+ console.log(err);
138+ }} else {{
139+ console.log('WebpackDevServer listening at localhost:', port);
140+ }}
129141}});
142+
143+
144+
130145""" .format (
131146 webpack_config = webpack_config .short_path ,
132147 # Directory containing the compiled source code of the js_library.
@@ -147,6 +162,7 @@ serve({{}}, {{
147162 internal_packages_dir = ctx .attr ._internal_packages [NpmPackagesInfo ].installed_dir .short_path ,
148163 # Template index.html for Webpack.
149164 html_template = ctx .file .html_template .short_path if ctx .file .html_template else "" ,
165+ dev_server_options = ctx .attr .lib [JsLibraryInfo ].compiled_javascript_dir .short_path + "/" + ctx .file .dev_server_options .short_path ,
150166 ),
151167 )
152168 ctx .actions .write (
@@ -270,6 +286,11 @@ _ATTRS = {
270286 ],
271287 default = "umd" ,
272288 ),
289+ "dev_server_options" : attr .label (
290+ allow_files = True ,
291+ single_file = True ,
292+ default = Label ("//internal/web_bundle:dev_server_options.js" ),
293+ ),
273294 "_internal_nodejs" : attr .label (
274295 allow_files = True ,
275296 single_file = True ,
0 commit comments