Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Merge feat/vue-multiple-build
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Nov 6, 2018
2 parents 4e89acf + 562d612 commit 5e8e339
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 35 deletions.
57 changes: 55 additions & 2 deletions packages/cli-plugin-vue/index.js
@@ -1,2 +1,55 @@
/* eslint-disable no-unused-vars */
module.exports = (api, config) => {};
/* eslint-disable no-unused-vars,no-case-declarations */
const path = require('path');
const { info, chalk, warn } = require('@vue/cli-shared-utils');
const fs = require('fs');
const multipleBuild = require('./src/command/multiple-build');

module.exports = (api, config) => {
api.registerCommand(
'vue',
{
usage: '<build|check> <pattern> [options]',
description: 'Build multiple vue app',
options: {
'-e, --execute <cmd>': {
type: String,
description: 'Run command to build a vue application'
}
}
},
async (commander, args) => {
const [mode = 'build', pattern = path.join(config.projectDir, '**')] = args;

switch (mode) {
case 'build':
info(`Starting build vue app...`);

await multipleBuild(config, {
cmd: commander.execute || 'vue-cli-service build --mode production',
pattern
});
break;

case 'check':
const { entries } = config.vueCli;

info(`Check entries for currentWebsite ${chalk.cyan(config.currentWebsite)}`);

entries.forEach(entry => {
entry.paths.forEach(file => {
if (!fs.existsSync(file)) {
warn(`Entry is KO: ${chalk.red(file)}`);
process.exit(-1);
}
});
});

info(`Entries is ok for the currentWebsite ${chalk.cyan(config.currentWebsite)}`);
break;

default:
break;
}
}
);
};
60 changes: 59 additions & 1 deletion packages/cli-plugin-vue/package-lock.json

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

4 changes: 3 additions & 1 deletion packages/cli-plugin-vue/package.json
Expand Up @@ -10,7 +10,9 @@
"@vue/cli-service": "^3.1.1",
"@vue/cli-shared-utils": "^3.1.1"
},
"dependencies": {},
"dependencies": {
"gulp-tap": "^1.0.1"
},
"directories": {
"src": "./src"
}
Expand Down
40 changes: 40 additions & 0 deletions packages/cli-plugin-vue/src/command/multiple-build.js
@@ -0,0 +1,40 @@
const path = require('path');
const gulp = require('gulp');
const tap = require('gulp-tap');
const { info, chalk } = require('@vue/cli-shared-utils');
const execa = require('execa');

module.exports = (config, options) =>
gulp.src(options.pattern).pipe(
tap(projectFolder => {
const currentWebsite = path.basename(projectFolder.path);

try {
execa.sync('nsc', ['vue', 'check', '--currentWebsite', currentWebsite], {
shell: true,
env: {
FORCE_COLOR: true
},
stdio: 'inherit'
});
} catch (er) {
return;
}

info(`Start build Project ${chalk.cyan(currentWebsite)}`);

let cmd = `${options.cmd}${options.cmd.match(/^npm/) ? ' -- ' : ''} --currentWebsite ${currentWebsite}`;
cmd = cmd.split(' ');

const task = cmd[0];
const args = cmd.splice(1).filter(t => !!t);

execa.sync(task, args, {
shell: true,
env: {
FORCE_COLOR: true
},
stdio: 'inherit'
});
})
);
1 change: 0 additions & 1 deletion packages/cli-plugin-vue/src/webpack/build.js
Expand Up @@ -33,7 +33,6 @@ module.exports = (config, baseVueConfig) => {
} else {
Object.keys(alias).forEach(key => {
const search = new RegExp(key.replace(/@/, '~'), 'gi');
info(search.toString());
sass.data = sass.data.replace(search, alias[key]);
});
}
Expand Down
41 changes: 11 additions & 30 deletions packages/cli/package-lock.json

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

0 comments on commit 5e8e339

Please sign in to comment.