mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
build: add files of vant-cli 2
This commit is contained in:
39
packages/vant-cli/src/commands/dev.ts
Normal file
39
packages/vant-cli/src/commands/dev.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import webpack from 'webpack';
|
||||
import WebpackDevServer from 'webpack-dev-server';
|
||||
import webpackDevConfig from '../config/webpack.site.dev';
|
||||
import { getPort } from 'portfinder';
|
||||
import { clean } from '../commands/clean';
|
||||
import { genMobileConfig } from '../compiler/gen-mobile-config';
|
||||
import { genDesktopConfig } from '../compiler/gen-desktop-config';
|
||||
|
||||
function runWebpack() {
|
||||
const server = new WebpackDevServer(
|
||||
webpack(webpackDevConfig),
|
||||
(webpackDevConfig as any).devServer
|
||||
);
|
||||
|
||||
getPort(
|
||||
{
|
||||
port: 8080
|
||||
},
|
||||
(err, port) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
server.listen(port, 'localhost', (err?: Error) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function dev() {
|
||||
clean();
|
||||
genMobileConfig();
|
||||
genDesktopConfig();
|
||||
runWebpack();
|
||||
}
|
Reference in New Issue
Block a user