Permalink
Browse files

chore: optimize webpack console output & config

  • Loading branch information...
1 parent 32a9f6c commit 4c3868339739ce5fcf2836e54e741d1baf146995 @meandmax committed Aug 26, 2016
Showing with 32 additions and 10 deletions.
  1. +2 −7 bin/compile.js
  2. +9 −3 bin/server.js
  3. +12 −0 webpack.config.base.js
  4. +4 −0 webpack.config.dev.js
  5. +5 −0 webpack.config.prod.js
View
@@ -2,16 +2,11 @@ import webpack from 'webpack';
import _debug from 'debug';
import fs from 'fs-extra';
import config from '../webpack.config.prod.js';
+import {COMPILER_STATS} from '../webpack.config.base.js';
const debug = _debug('app:build:webpack-compiler');
-const DEFAULT_STATS_FORMAT = {
- chunks : false,
- chunkModules : false,
- colors : true
- }
-
-function webpackCompiler (webpackConfig, statsFormat = DEFAULT_STATS_FORMAT) {
+function webpackCompiler (webpackConfig, statsFormat = COMPILER_STATS) {
return new Promise((resolve, reject) => {
const compiler = webpack(webpackConfig);
View
@@ -1,11 +1,17 @@
import webpack from 'webpack';
import config from '../webpack.config.dev.js';
+import _debug from 'debug';
import WebpackDevServer from 'webpack-dev-server';
+import {COMPILER_STATS, PORT} from '../webpack.config.base.js';
-config.entry.app.unshift("webpack-dev-server/client?http://localhost:8080/", "webpack/hot/dev-server");
+const debug = _debug('app:server');
+
+config.entry.app.unshift(`webpack-dev-server/client?http://localhost:${PORT}/`, "webpack/hot/dev-server");
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, {
- hot: true
+ hot: true,
+ stats: COMPILER_STATS
});
-server.listen(8080);
+debug(`Start webpack-dev-server on port: ${PORT}`);
+server.listen(PORT);
@@ -1,7 +1,19 @@
import path from 'path';
+import _debug from 'debug';
var ROOT_PATH = path.resolve(__dirname);
+const debug = _debug('app:webpack:config');
+debug('Create configuration.');
+
+export const COMPILER_STATS = {
+ chunks: true,
+ chunkModules: true,
+ colors: true
+};
+
+export const PORT = 8080;
+
export default {
entry: {
"lory": ["./src/lory.js"],
@@ -1,10 +1,14 @@
import webpack from 'webpack';
import baseConfig from './webpack.config.base';
import HtmlWebpackPlugin from 'html-webpack-plugin';
+import _debug from 'debug';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
let config = Object.create(baseConfig);
+const debug = _debug('app:webpack:config');
+debug('Enable plugins for live development (HMR, NoErrors).');
+
config.plugins = [
new HtmlWebpackPlugin({
template: 'src/index.html'
@@ -2,6 +2,11 @@ import webpack from 'webpack';
import baseConfig from './webpack.config.base';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
+import _debug from 'debug';
+
+
+const debug = _debug('app:webpack:config');
+debug('Enable plugins for production (Dedupe & UglifyJS).');
let config = Object.create(baseConfig);

0 comments on commit 4c38683

Please sign in to comment.