Skip to content

Commit f6b6224

Browse files
authored
Merge pull request #81 from ice-lab/feat-skip-build
feat: cli option for skip webpack compile
2 parents e7e1cfe + 873cdac commit f6b6224

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.1.15
4+
5+
- [feat] cli option --skip-compile for skip webpack compile
6+
37
## 2.1.14
48

59
- [feat] support postcssrc/postcss.config.js #2952

packages/ice-scripts/bin/ice-scripts-build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ program
88
.option('--config <config>', 'use custom config')
99
.option('--analyzer', '开启构建分析')
1010
.option('--analyzer-port', '设置分析端口号')
11+
.option('--skip-compile', 'skip webpack compile, excute hooks for component compile')
1112
.parse(process.argv);
1213

1314
(async () => {

packages/ice-scripts/lib/commands/build.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,34 @@ module.exports = async function (context) {
4343
}
4444
}
4545

46-
// empty output path
47-
fse.emptyDirSync(webpackConfig.output.path);
48-
return new Promise((resolve, reject) => {
49-
webpack(webpackConfig, (error, stats) => {
50-
if (error) {
51-
return reject(error);
52-
}
53-
console.log(
54-
stats.toString({
55-
colors: true,
56-
chunks: false,
57-
children: false,
58-
modules: false,
59-
chunkModules: false,
60-
})
61-
);
62-
if (stats.hasErrors()) {
63-
return reject(new Error('webpack compiled failed.'));
64-
}
65-
log.info('ICE build finished');
66-
applyHook('afterBuild', stats);
67-
resolve();
46+
const skipCompile = commandArgs.skipCompile || process.env.SKIP_COMPILE;
47+
if (skipCompile) {
48+
applyHook('afterBuild', {});
49+
return Promise.resolve();
50+
} else {
51+
// empty output path
52+
fse.emptyDirSync(webpackConfig.output.path);
53+
return new Promise((resolve, reject) => {
54+
webpack(webpackConfig, (error, stats) => {
55+
if (error) {
56+
return reject(error);
57+
}
58+
console.log(
59+
stats.toString({
60+
colors: true,
61+
chunks: false,
62+
children: false,
63+
modules: false,
64+
chunkModules: false,
65+
}),
66+
);
67+
if (stats.hasErrors()) {
68+
return reject(new Error('webpack compiled failed.'));
69+
}
70+
log.info('ICE build finished');
71+
applyHook('afterBuild', stats);
72+
resolve();
73+
});
6874
});
69-
});
75+
}
7076
};

0 commit comments

Comments
 (0)