Skip to content

Commit

Permalink
Run Webpack within mdn-bob script (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Nov 10, 2022
1 parent 2f4b9bf commit 6e800ed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions lib/mdn-bob.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
#!/usr/bin/env node

import fse from "fs-extra";
import webpack from "webpack";

import webpackConfig from "../webpack.config.js";
import getConfig from "./config.js";
import * as pageBuilder from "./pageBuilder.js";
import * as utils from "./utils.js";

function doWebpack() {
return new Promise((resolve, reject) => {
webpack(webpackConfig, (err, stats) => {
const statsJson = stats.toJson();

if (err || stats.hasErrors()) {
if (err) {
throw err;
}
reject(statsJson.errors);
}

if (stats.hasWarnings()) {
for (const warn of statsJson.warnings) {
console.warn("Webpack Warning: " + warn.message);
}
}

resolve();
});
});
}

/**
* Initialization of the module. Calls the follow on functions to generate the pages.
*/
Expand All @@ -19,6 +45,9 @@ async function init() {
console.info("MDN-BOB: Copying static assets....");
utils.copyStaticAssets();

console.info("MDN-BOB: Running Webpack...");
await doWebpack();

console.info("MDN-BOB: Building pages....");
console.log(await pageBuilder.buildPages());

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
],
"scripts": {
"build": "node ./lib/mdn-bob.js && webpack",
"build": "node ./lib/mdn-bob.js",
"start": "npm-run-all build start-server",
"start-server": "http-server -p 4444 ./docs",
"format": "prettier --ignore-unknown --check \"*\"",
Expand Down

0 comments on commit 6e800ed

Please sign in to comment.