Skip to content

Commit ab8d718

Browse files
author
chengyu.chengyulia
committed
feat: support mode in webpack-dev-server
1 parent 4d0368c commit ab8d718

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/built-in-plugins/command-bundle/plugin/command-bundle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const commandBundle = async (opts: IOpts = {}) => {
4141
await bundleDlls({ dllOutPath, dllFileName, dllMainfestName });
4242

4343
runWebpackDevServer({
44-
mode: 'development',
44+
mode: opts.mode ?? 'development',
4545
outFileName: pri.sourceConfig.bundleFileName,
4646
devServerPort: freePort,
4747
publicPath: `https://localhost:${freePort}`,

src/built-in-plugins/command-bundle/plugin/interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export interface IOpts {
22
skipLint?: boolean;
33
dev?: boolean;
44
publicPath?: string;
5+
mode?: 'development' | 'production';
56
}

src/built-in-plugins/command-dev/plugin/project-dev.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const projectDev = async (options: any) => {
2626
if (options && options.debugDashboard) {
2727
await debugDashboard();
2828
} else {
29-
await debugProject();
29+
await debugProject(options);
3030
}
3131
};
3232

@@ -62,7 +62,7 @@ async function debugDashboard() {
6262
});
6363
}
6464

65-
async function debugProject() {
65+
async function debugProject(options?: any) {
6666
const freePort = pri.sourceConfig.devPort || (await portfinder.getPortPromise());
6767
const dashboardServerPort = await portfinder.getPortPromise({ port: freePort + 1 });
6868
const dashboardClientPort = await portfinder.getPortPromise({ port: freePort + 2 });
@@ -142,7 +142,7 @@ async function debugProject() {
142142

143143
// Serve project
144144
await runWebpackDevServer({
145-
mode: 'development',
145+
mode: options?.mode ?? 'development',
146146
autoOpenBrowser: true,
147147
hot: pri.sourceConfig.hotReload,
148148
publicPath: globalState.sourceConfig.publicPath,

0 commit comments

Comments
 (0)