verdaccio-ui/tools/dev.server.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-04-05 02:23:40 +07:00
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import config from './webpack.dev.config.babel';
import ora from 'ora';
import env from '../src/config/env';
2019-02-03 17:23:33 +07:00
const compiler = webpack(config);
2019-04-05 02:23:40 +07:00
const spinner = ora('Compiler is running...').start();
compiler.hooks.done.tap('Verdaccio Dev Server', () => {
2019-02-03 17:23:33 +07:00
if (!global.rebuild) {
spinner.stop();
2019-04-05 02:23:40 +07:00
console.log('Dev Server Listening at http://localhost:4872/');
2019-02-03 17:23:33 +07:00
global.rebuild = true;
}
});
new WebpackDevServer(compiler, {
2019-04-05 02:23:40 +07:00
contentBase: `${env.DIST_PATH}`,
2019-02-03 17:23:33 +07:00
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
quiet: true,
noInfo: false,
stats: {
assets: false,
colors: true,
version: true,
hash: true,
timings: true,
chunks: true,
2019-04-05 02:23:40 +07:00
chunkModules: false,
2019-02-03 17:23:33 +07:00
},
2019-04-05 02:23:40 +07:00
proxy: [{
context: ['/-/verdaccio/logo', '/-/verdaccio/packages', '/-/static/logo.png'],
target: 'http://localhost:4873',
}],
}).listen(4872, 'localhost', function(err) {
2019-02-03 17:23:33 +07:00
if (err) {
return console.log(err);
}
});