Skip to content

Commit

Permalink
Merge pull request #133 from monaca/fix_monaca_preview_to_write_files…
Browse files Browse the repository at this point in the history
…_to_www

monaca preview to write files to www
  • Loading branch information
yong-asial authored Jul 6, 2018
2 parents cc85c47 + 99cce46 commit a1d404e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
====

v2.7.7
----
* Appended `webpack-dev-server/client` to webpack configuration only if `inline` and `hot` are set to true
* Appended `webpack-dev-server/client` to `entry.watch` if supplied
* Modified `monaca preview` to write files to `www` directory in `monaca-lib@2.7.7` so that the `monaca debugger` will see the changes immediately without running `monaca transpile`

v2.7.6
----
* Added `skipTranspile` option to `monaca upload` to skip transpiling if supplied
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaca",
"version": "2.7.6",
"version": "2.7.7",
"description": "Monaca Command Line Tool",
"bin": {
"monaca": "bin/monaca"
Expand Down Expand Up @@ -29,17 +29,17 @@
"homepage": "https://monaca.io",
"preferGlobal": true,
"dependencies": {
"hoek": "^5.0.3",
"browser-sync": "^2.23.6",
"colors": "^0.6.2",
"compare-versions": "3.0.1",
"cordova": "7.1.0",
"extend": "^2.0.0",
"global-npm": "^0.3.0",
"hoek": "^5.0.3",
"ip": "^1.1.5",
"live-server": "1.2.0",
"monaca-inquirer": "^1.0.4",
"monaca-lib": "2.7.6",
"monaca-lib": "^2.7.7",
"open": "0.0.5",
"optimist": "^0.6.1",
"portfinder": "^1.0.7",
Expand Down
43 changes: 27 additions & 16 deletions src/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,38 @@
};
};

// Webpack Dev Server
var webpack = require(path.join(monaca.userCordova, 'node_modules', 'webpack'));
var webpackConfig = require(monaca.getWebpackConfigFile(projectDir, 'dev'));
try {
// Webpack Dev Server
var webpack = require(path.join(monaca.userCordova, 'node_modules', 'webpack'));
var webpackConfig = require(monaca.getWebpackConfigFile(projectDir, 'dev'));

if (webpackConfig.devServer.inline) {
var packUrl = taskName === 'demo' ? "http://localhost:" + nextPort + "/": "http://localhost:" + port + "/";
if (webpackConfig.devServer.inline) {
var packUrl = taskName === 'demo' ? "http://localhost:" + nextPort + "/": "http://localhost:" + port + "/";

if (terminal.isOnMonaca) {
packUrl = "https://0.0.0.0/";
webpackConfig.devServer.disableHostCheck = true;
}
if (terminal.isOnMonaca) {
packUrl = "https://0.0.0.0/";
webpackConfig.devServer.disableHostCheck = true;
}

// add webpack-dev-server client socket if inline and hot are set to true
if (webpackConfig.devServer.inline && webpackConfig.devServer.hot) {
if (webpackConfig.entry.watch && webpackConfig.entry.watch instanceof Array) {
webpackConfig.entry.watch.unshift("webpack-dev-server/client?" + packUrl);
} else if (webpackConfig.entry.app && webpackConfig.entry.app instanceof Array) {
webpackConfig.entry.app.unshift("webpack-dev-server/client?" + packUrl);
} else if (webpackConfig.entry && webpackConfig.entry instanceof Array) {
webpackConfig.entry.unshift("webpack-dev-server/client?" + packUrl);
}
}

if (webpackConfig.entry.app && webpackConfig.entry.app instanceof Array) {
webpackConfig.entry.app.unshift("webpack-dev-server/client?" + packUrl);
} else if (webpackConfig.entry && webpackConfig.entry instanceof Array) {
webpackConfig.entry.unshift("webpack-dev-server/client?" + packUrl);
}
}

var WebpackDevServer = require(path.join(monaca.userCordova, 'node_modules', 'webpack-dev-server'));
var server = new WebpackDevServer(webpack(webpackConfig), webpackConfig.devServer);
var WebpackDevServer = require(path.join(monaca.userCordova, 'node_modules', 'webpack-dev-server'));
var server = new WebpackDevServer(webpack(webpackConfig), webpackConfig.devServer);

} catch (e) {
console.log('webpack error', e);
}

// Different port number
if (taskName === 'demo') {
Expand Down

0 comments on commit a1d404e

Please sign in to comment.