Browse Source

Displaying fancier build status during dev server

docs
Eli Perelman 8 years ago
parent
commit
33d83cce45
  1. 1
      packages/neutrino/package.json
  2. 21
      packages/neutrino/src/neutrino.js
  3. 46
      packages/neutrino/yarn.lock

1
packages/neutrino/package.json

@ -15,6 +15,7 @@
"license": "MPL-2.0",
"repository": "mozilla-neutrino/neutrino-dev",
"dependencies": {
"ora": "^1.1.0",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0",
"webpack-merge": "^2.6.1",

21
packages/neutrino/src/neutrino.js

@ -3,11 +3,11 @@ const EventEmitter = require('events').EventEmitter;
const merge = require('webpack-merge').smart;
const DevServer = require('webpack-dev-server');
const webpack = require('webpack');
const ora = require('ora');
const cwd = process.cwd();
const noop = Function.prototype;
module.exports = class Neutrino extends EventEmitter {
class Neutrino extends EventEmitter {
constructor(presets) {
super();
this.configs = [];
@ -134,19 +134,26 @@ module.exports = class Neutrino extends EventEmitter {
_devServer() {
return new Promise(resolve => {
const starting = ora('Starting development server').start();
const config = this.getConfig();
const protocol = config.devServer.https ? 'https' : 'http';
const host = config.devServer.host || 'localhost';
const port = config.devServer.port || 5000;
config.devServer.noInfo = true;
const compiler = webpack(config);
const server = new DevServer(compiler, config.devServer);
const building = ora('Waiting for initial build to finish').start();
process.on('SIGINT', resolve);
server.listen(port, host, () => {
console.log(`Dev server started at ${protocol}://${host}:${port}`);
console.log('Waiting for initial build to finish...');
starting.succeed(`Development server running on: ${protocol}://${host}:${port}`);
compiler.plugin('compile', () => {
building.text = 'Source changed, re-compiling';
building.start();
});
compiler.plugin('done', () => building.succeed('Build completed'));
});
});
}
@ -160,4 +167,6 @@ module.exports = class Neutrino extends EventEmitter {
extend(source, extender) {
return extender(source(this));
}
};
}
module.exports = Neutrino;

46
packages/neutrino/yarn.lock

@ -309,7 +309,7 @@ center-align@^0.1.1:
align-text "^0.1.3"
lazy-cache "^1.0.3"
chalk@^1.1.1:
chalk@^1.0.0, chalk@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
dependencies:
@ -340,6 +340,16 @@ cipher-base@^1.0.0, cipher-base@^1.0.1:
dependencies:
inherits "^2.0.1"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
dependencies:
restore-cursor "^2.0.0"
cli-spinners@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.0.0.tgz#ef987ed3d48391ac3dab9180b406a742180d6e6a"
cliui@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"
@ -1193,6 +1203,12 @@ lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
log-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18"
dependencies:
chalk "^1.0.0"
longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
@ -1255,6 +1271,10 @@ mime@1.3.4, mime@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"
mimic-fn@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
minimalistic-assert@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz#702be2dda6b37f4836bcb3f5db56641b64a1d3d3"
@ -1404,6 +1424,12 @@ once@^1.3.0, once@~1.3.3:
dependencies:
wrappy "1"
onetime@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.0.tgz#52aa8110e52fc5126ffc667bd8ec21c2ed209ce6"
dependencies:
mimic-fn "^1.0.0"
opn@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95"
@ -1411,6 +1437,15 @@ opn@4.0.2:
object-assign "^4.0.1"
pinkie-promise "^2.0.0"
ora@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ora/-/ora-1.1.0.tgz#69aaa4a209630e43b142c5f7ff41820da87e2faf"
dependencies:
chalk "^1.1.1"
cli-cursor "^2.1.0"
cli-spinners "^1.0.0"
log-symbols "^1.0.2"
original@>=0.0.5:
version "1.0.0"
resolved "https://registry.yarnpkg.com/original/-/original-1.0.0.tgz#9147f93fa1696d04be61e01bd50baeaca656bd3b"
@ -1699,6 +1734,13 @@ requires-port@1.0.x, requires-port@1.x.x:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
dependencies:
onetime "^2.0.0"
signal-exit "^3.0.2"
right-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
@ -1784,7 +1826,7 @@ sha.js@^2.3.6:
dependencies:
inherits "^2.0.1"
signal-exit@^3.0.0:
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"

Loading…
Cancel
Save