forked from tracking-exposed/web-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-server.js
41 lines (33 loc) · 1.19 KB
/
dev-server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint-disable strict, no-console */
/* eslint-disable import/no-extraneous-dependencies, import/newline-after-import */
'use strict';
const path = require('path');
const WebpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');
const config = require('./webpack.config.js');
require('dotenv').load({ silent: true });
const HOST_NAME = process.env.DEMO_HOST_NAME || 'localhost';
const PORT = process.env.DEMO_PORT || 3000;
// Manipulate webpack entry for demo server; only use demo app
config.entry = [path.resolve(__dirname, 'src/app')];
// Specify output location for bundled files
config.output.publicPath = '/assets/';
// Configure server
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, {
publicPath: config.output.publicPath,
historyApiFallback: {
index: '/'
},
noInfo: true,
stats: { colors: true }
});
// Start server
server.listen(PORT, HOST_NAME, (err) => {
if (err) {
console.error(`Demo server ran into ${err} while starting on ${HOST_NAME}:${PORT}. ` +
'Shutting down...');
server.close();
}
console.log(`Demo server running on ${HOST_NAME}:${PORT}`);
});