Skip to content

Commit

Permalink
Merge pull request #84 from mm-vasyl/parallel-webpacks
Browse files Browse the repository at this point in the history
Parallel webpacks
  • Loading branch information
mm-paulie authored Nov 16, 2023
2 parents 8ccb620 + b89dd6b commit 461ccc4
Show file tree
Hide file tree
Showing 16 changed files with 451 additions and 81 deletions.
1 change: 1 addition & 0 deletions cli/displayDevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ program
.option('-o, --outputDir <data>', 'output dir', './build')
.option('--skipBuild', 'skip compiling ads phase', false)
.option('--skipPreview', 'skip preview building phase', false)
.option('-p, --parallel [data]', 'run webpack in parallel')
.parse(process.argv);

const options = program.opts();
Expand Down
64 changes: 57 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"webpack": "^5.75.0",
"webpack-dev-middleware": "^6.0.1",
"webpack-hot-middleware": "^2.25.3",
"webpack-virtual-modules": "^0.5.0"
"webpack-virtual-modules": "^0.5.0",
"worker-farm": "^1.7.0"
}
}
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
const getWebpackConfigs = require("./webpack/getWebpackConfigs");
const devServer = require("./webpack/devServer");
const devServerParallel = require("./webpack/devServerParallel");
const buildFiles = require("./webpack/buildFiles");
const buildFilesParallel = require("./webpack/buildFilesParallel");
const buildPreview = require("./webpack/buildPreview");

module.exports = async function (options) {
// {mode = "development", glob = "./**/.richmediarc*", choices = null, stats = null, outputDir = "./build", configOverride = {}}
let {mode, glob, choices, stats, outputDir, skipBuild, skipPreview} = options;
let {mode, glob, choices, stats, outputDir, skipBuild, skipPreview, parallel} = options;

const webpackConfigs = !skipBuild ? await getWebpackConfigs(options) : null;

if (mode === "development") {
await devServer(webpackConfigs.result, webpackConfigs.choices.openLocation);
if (parallel) await devServerParallel(webpackConfigs.result, webpackConfigs.choices.openLocation, options);
else await devServer(webpackConfigs.result, webpackConfigs.choices.openLocation);
} else {
if (!skipBuild) await buildFiles(webpackConfigs.result, outputDir);
if (!skipBuild) {
if (parallel) await buildFilesParallel(webpackConfigs.result, options);
else await buildFiles(webpackConfigs.result, outputDir);
}
if (!skipPreview) await buildPreview(webpackConfigs?.result, outputDir);
}
};
Loading

0 comments on commit 461ccc4

Please sign in to comment.