Skip to content

Commit

Permalink
fix: ensure to have exact webpack CLI command (#1728)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Sep 1, 2020
1 parent 677dec7 commit 50d262d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions packages/xarc-app-dev/src/lib/load-xrun-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ const xsh = require("xsh");

require("../typedef");

/**
* Get the webpack's CLI command from @xarc/webpack
*
* @returns webpack's CLI command
*/
function webpackCmd() {
const exactCmd = Path.join(
Path.dirname(require.resolve("@xarc/webpack/package.json")),
"node_modules",
".bin",
"webpack"
);
return Fs.existsSync(exactCmd) ? exactCmd : `webpack`;
}

/**
* @param {object} xclap xclap task runner
* @param {CreateXarcOptions} [userXarcOptions] user provided options to configure archetype generation
Expand Down Expand Up @@ -461,7 +476,7 @@ module.exports = function loadArchetype(xclap, userXarcOptions) {
setProductionEnv();
setWebpackProfile("browsercoverage");
return exec(
`webpack`,
`${webpackCmd()}`,
`--config`,
quote(getWebpackStartConfig("webpack.config.browsercoverage.js")),
`--colors`
Expand Down Expand Up @@ -506,7 +521,7 @@ module.exports = function loadArchetype(xclap, userXarcOptions) {
task: function() {
setWebpackProfile("static");
return mkCmd(
`~$webpack --config`,
`~$${webpackCmd()} --config`,
quote(getWebpackStartConfig("webpack.config.dev.static.js")),
`--colors`,
`--display-error-details`
Expand Down Expand Up @@ -539,7 +554,7 @@ module.exports = function loadArchetype(xclap, userXarcOptions) {
babelEnvTargetsArr.map((name, index) =>
xclap2.exec(
[
`webpack --config`,
`${webpackCmd()} --config`,
quote(getWebpackStartConfig("webpack.config.js")),
`--colors --display-error-details`
],
Expand Down Expand Up @@ -1017,7 +1032,7 @@ module.exports = function loadArchetype(xclap, userXarcOptions) {
task: () => {
setWebpackProfile("dll");
return exec(
`webpack --config`,
`${webpackCmd()} --config`,
quote(getWebpackStartConfig("webpack.config.dll.js")),
`--colors`,
`--display-error-details`
Expand Down

0 comments on commit 50d262d

Please sign in to comment.