Skip to content

Commit 3af4e79

Browse files
committed
Making the "start" dev script to open the browser automatically
1 parent b2236f7 commit 3af4e79

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

demo/server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import * as webpackMiddleware from 'webpack-dev-middleware';
55
import * as webpackHotMiddleware from 'webpack-hot-middleware';
66
import * as webpack from 'webpack';
77
import * as webpackConfig from '../webpack.config.demo.dev';
8+
import * as opn from 'opn';
89
const packageJson = require('../package.json');
910

1011
const webpackCompiler = webpack(webpackConfig as any);
12+
const port = 4000;
1113

1214
require.extensions['.html'] = (module, filename) => {
1315
module.exports = fs.readFileSync(filename, 'utf8');
@@ -19,6 +21,8 @@ app.use(webpackMiddleware(webpackCompiler));
1921
app.use(webpackHotMiddleware(webpackCompiler));
2022
app.use((req, res) => res.status(200).send(require('./index.html')));
2123

22-
app.listen(4000, '0.0.0.0', () => {
23-
console.log(colors.green(`${packageJson.name} at http://localhost:4000/`));
24+
app.listen(port, '0.0.0.0', () => {
25+
const demoUrl = `http://localhost:${port}/`;
26+
console.log(colors.green(`${packageJson.name} at ${demoUrl}`));
27+
opn(demoUrl);
2428
});

0 commit comments

Comments
 (0)