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

优化打开默认浏览器的时机,由webpack-dev-server启动成功打开,改为编译完成之后打开,以降低Node.js内存占用率 #3

Open
wants to merge 1 commit into
base: master
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"chalk": "^2.4.1",
"change-case": "^3.0.1",
"choerodon-ui": "0.5.4",
"choerodon-ui": "0.5.3",
"classnames": "^2.2.5",
"commander": "^2.9.0",
"component-classes": "^1.x",
Expand Down Expand Up @@ -88,6 +88,7 @@
"node-sass": "^4.7.2",
"nunjucks": "^3.1.3",
"object.omit": "^3.0.0",
"open-browser-webpack-plugin": "0.0.5",
"postcss-loader": "^2.1.5",
"prop-types": "^15.5.10",
"query-string": "^4.1.0",
Expand Down
9 changes: 7 additions & 2 deletions src/bin/start.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import path from 'path';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import openBrowser from 'react-dev-utils/openBrowser';
// import openBrowser from 'react-dev-utils/openBrowser';
import OpenBrowserPlugin from 'open-browser-webpack-plugin';
import updateWebpackConfig from '../config/updateWebpackConfig';
import context from './common/context';
import generateEntryFile from './common/generateEntryFile';
Expand All @@ -11,6 +12,7 @@ import installSubmoduleDependencies from './common/installSubmoduleDependencies'

function run(mainPackage, dev) {
const { choerodonConfig: { entryName, devServerConfig, output, port } } = context;

generateEntryFile(
mainPackage,
entryName,
Expand All @@ -19,6 +21,7 @@ function run(mainPackage, dev) {

const webpackConfig = updateWebpackConfig('start', 'development');
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
webpackConfig.plugins.push(new OpenBrowserPlugin({ url: `http://localhost:${port}` }));
const serverOptions = {
quiet: true,
hot: true,
Expand All @@ -43,7 +46,9 @@ function run(mainPackage, dev) {
const server = new WebpackDevServer(compiler, serverOptions);
server.listen(
port, '0.0.0.0',
() => openBrowser(`http://localhost:${port}`),
() => {
// openBrowser(`http://localhost:${port}`)
},
);
}

Expand Down