Skip to content

Commit 40389d1

Browse files
committed
chore(webpack): add webpackbar support, improve logging
1 parent fefb823 commit 40389d1

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

src/module.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import _ from "lodash";
77
import { r, urlJoin } from "@nuxt/common";
88
import consola from "consola";
99
import chokidar from "chokidar";
10+
import env from "std-env";
1011
import pify from "pify";
1112
import webpack from "webpack";
1213
import webpackDevMiddleware from "webpack-dev-middleware";
1314
import webpackHotMiddleware from "webpack-hot-middleware";
15+
import WebpackBar from "webpackbar";
1416
import serveStatic from "serve-static";
1517

1618
import pkg from "../package.json";
@@ -64,6 +66,34 @@ export default function NetlifyCmsModule(moduleOptions) {
6466
}
6567
});
6668

69+
webpackConfig.plugins.push(
70+
new WebpackBar({
71+
name: WEBPACK_NETLIFY_COMPILER_NAME,
72+
color: "red",
73+
reporters: ["basic", "fancy", "profile", "stats"],
74+
basic: !this.options.build.quiet && env.minimalCLI,
75+
fancy: !this.options.build.quiet && !env.minimalCLI,
76+
profile: !this.options.build.quiet && this.options.build.profile,
77+
stats:
78+
!this.options.build.quiet &&
79+
!this.options.dev &&
80+
this.options.build.stats,
81+
reporter: {
82+
change: (_, { shortPath }) => {
83+
this.nuxt.callHook("bundler:change", shortPath);
84+
},
85+
done: context => {
86+
if (context.hasErrors) {
87+
this.nuxt.callHook("bundler:error");
88+
}
89+
},
90+
allDone: () => {
91+
this.nuxt.callHook("bundler:done");
92+
}
93+
}
94+
})
95+
);
96+
6797
const netlifyCompiler = webpack(webpackConfig);
6898

6999
// This will be run just before webpack compiler starts
@@ -84,7 +114,6 @@ export default function NetlifyCmsModule(moduleOptions) {
84114
return;
85115
}
86116

87-
logger.success("Netlify-cms bundle generated");
88117
// Show a message inside console when the build is ready
89118
this.options.dev &&
90119
logger.info(`Netlify-cms served on: ${config.adminPath}`);
@@ -102,12 +131,14 @@ export default function NetlifyCmsModule(moduleOptions) {
102131
const netlifyWebpackDevMiddleware = pify(
103132
webpackDevMiddleware(netlifyCompiler, {
104133
publicPath: "/",
105-
stats: builder.webpackStats,
106-
noInfo: true,
107-
quiet: true,
134+
stats: false,
135+
logLevel: "silent",
108136
watchOptions: this.options.watchers.webpack
109137
})
110138
);
139+
netlifyWebpackDevMiddleware.close = pify(
140+
netlifyWebpackDevMiddleware.close
141+
);
111142

112143
// Create webpack hot middleware
113144
const netlifyWebpackHotMiddleware = pify(

0 commit comments

Comments
 (0)