refactor: move to serveBundle

This commit is contained in:
Ivan Shmidt
2020-05-18 18:19:56 +02:00
parent dd93bc9ced
commit aef288b6cb
4 changed files with 5 additions and 15 deletions
+1 -7
View File
@@ -14,19 +14,13 @@
* limitations under the License.
*/
import fs from 'fs-extra';
import { Command } from 'commander';
import { serveBundle } from '../../lib/bundler';
import { paths } from '../../lib/paths';
import { Command } from 'commander';
export default async (cmd: Command) => {
const pkgPath = paths.resolveTarget('package.json');
const pkg = await fs.readJson(pkgPath);
const waitForExit = await serveBundle({
entry: 'src/index',
checksEnabled: cmd.check,
proxy: pkg.proxy,
});
await waitForExit();
@@ -14,19 +14,13 @@
* limitations under the License.
*/
import fs from 'fs-extra';
import { serveBundle } from '../../lib/bundler';
import { Command } from 'commander';
import { paths } from '../../lib/paths';
export default async (cmd: Command) => {
const pkgPath = paths.resolveTarget('package.json');
const pkg = await fs.readJson(pkgPath);
const waitForExit = await serveBundle({
entry: 'dev/index',
checksEnabled: cmd.check,
proxy: pkg.proxy,
});
await waitForExit();
+4
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import fs from 'fs-extra';
import yn from 'yn';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
@@ -36,6 +37,8 @@ export async function serveBundle(options: ServeOptions) {
const urls = prepareUrls(protocol, host, port);
const paths = resolveBundlingPaths(options);
const pkgPath = paths.targetPackageJson;
const pkg = await fs.readJson(pkgPath);
const config = createConfig(paths, { ...options, isDev: true });
const compiler = webpack(config);
@@ -48,6 +51,7 @@ export async function serveBundle(options: ServeOptions) {
https: protocol === 'https',
host,
port,
proxy: pkg.proxy,
});
await new Promise((resolve, reject) => {
-2
View File
@@ -15,7 +15,6 @@
*/
import { BundlingPathsOptions } from './paths';
import { ProxyConfigMap } from 'webpack-dev-server';
export type BundlingOptions = {
checksEnabled: boolean;
@@ -24,7 +23,6 @@ export type BundlingOptions = {
export type ServeOptions = BundlingPathsOptions & {
checksEnabled: boolean;
proxy?: ProxyConfigMap;
};
export type BuildOptions = BundlingPathsOptions & {