Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support watch mode in modern build #6470

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thick-fans-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modern-js/app-tools': patch
---

feat: support watch mode in modern build
1 change: 1 addition & 0 deletions packages/document/main-doc/docs/en/apis/app/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Usage: modern build [options]
Options:
-c --config <config> specify the configuration file, which can be a relative or absolute path
-h, --help show command help
-w --watch turn on watch mode, watch for changes and rebuild
--analyze analyze the bundle and view size of each module
```

Expand Down
1 change: 1 addition & 0 deletions packages/document/main-doc/docs/zh/apis/app/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Usage: modern build [options]
Options:
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
-h, --help 显示命令帮助
-w --watch 开启 watch 模式, 监听文件变更并重新构建
--analyze 分析构建产物体积,查看各个模块打包后的大小
```

Expand Down
4 changes: 3 additions & 1 deletion packages/solutions/app-tools/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ export const build = async (
'Expect the Builder to have been initialized, But the appContext.builder received `undefined`',
);
}
await appContext.builder.build();
await appContext.builder.build({
watch: options?.watch,
});
};
1 change: 1 addition & 0 deletions packages/solutions/app-tools/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const buildCommand = async (
.description(i18n.t(localeKeys.command.build.describe))
.option('-c --config <config>', i18n.t(localeKeys.command.shared.config))
.option('--analyze', i18n.t(localeKeys.command.shared.analyze))
.option('-w --watch', i18n.t(localeKeys.command.build.watch))
.action(async (options: BuildOptions) => {
const { build } = await import('./build.js');
await build(api, options);
Expand Down
1 change: 1 addition & 0 deletions packages/solutions/app-tools/src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const EN_LOCALE = {
},
build: {
describe: 'build the app for production',
watch: 'turn on watch mode, watch for changes and rebuild',
},
serve: { describe: 'preview the production build locally' },
deploy: { describe: 'deploy the application' },
Expand Down
1 change: 1 addition & 0 deletions packages/solutions/app-tools/src/locale/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ZH_LOCALE = {
},
build: {
describe: '构建生产环境产物',
watch: '开启 watch 模式, 监听文件变更并重新构建',
},
serve: { describe: '启动生产环境服务' },
deploy: { describe: '部署应用' },
Expand Down
1 change: 1 addition & 0 deletions packages/solutions/app-tools/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type DevOptions = {
export type BuildOptions = {
config?: string;
analyze?: boolean;
watch?: boolean;
};

export type DeployOptions = {
Expand Down
Loading