Skip to content

Commit 6dbf666

Browse files
committed
Also include beautifying for client scripts.
consistency++
1 parent e6e5481 commit 6dbf666

File tree

4 files changed

+47
-22
lines changed

4 files changed

+47
-22
lines changed

client/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ function getCurrentScriptSource() {
1010
// Fall back to getting all scripts in the document.
1111
var scriptElements = document.scripts || [];
1212
var currentScript = scriptElements[scriptElements.length - 1];
13-
if (currentScript)
13+
if(currentScript)
1414
return currentScript.getAttribute("src");
1515
// Fail as there was no script to use.
1616
throw new Error("[WDS] Failed to get current script source");
1717
}
1818

1919
var urlParts;
20-
if (typeof __resourceQuery === "string" && __resourceQuery) {
20+
if(typeof __resourceQuery === "string" && __resourceQuery) {
2121
// If this bundle is inlined, use the resource query to get the correct url.
2222
urlParts = url.parse(__resourceQuery.substr(1));
2323
} else {

client/live.js

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ $(function() {
3838
var contentPage = window.location.pathname.substr("/webpack-dev-server".length) + window.location.search;
3939

4040
status.text("Connecting to sockjs server...");
41-
$errors.hide(); iframe.hide();
42-
header.css({borderColor: "#96b5b4"});
41+
$errors.hide();
42+
iframe.hide();
43+
header.css({
44+
borderColor: "#96b5b4"
45+
});
4346

4447
var onSocketMsg = {
4548
hot: function() {
@@ -49,17 +52,23 @@ $(function() {
4952
invalid: function() {
5053
okness.text("");
5154
status.text("App updated. Recompiling...");
52-
header.css({borderColor: "#96b5b4"});
53-
$errors.hide(); if(!hot) iframe.hide();
55+
header.css({
56+
borderColor: "#96b5b4"
57+
});
58+
$errors.hide();
59+
if(!hot) iframe.hide();
5460
},
5561
hash: function(hash) {
5662
currentHash = hash;
5763
},
5864
"still-ok": function() {
5965
okness.text("");
6066
status.text("App ready.");
61-
header.css({borderColor: ""});
62-
$errors.hide(); if(!hot) iframe.show();
67+
header.css({
68+
borderColor: ""
69+
});
70+
$errors.hide();
71+
if(!hot) iframe.show();
6372
},
6473
ok: function() {
6574
okness.text("");
@@ -75,30 +84,41 @@ $(function() {
7584
status.text("App updated with errors. No reload!");
7685
okness.text("Errors while compiling.");
7786
$errors.text("\n" + stripAnsi(errors.join("\n\n\n")) + "\n\n");
78-
header.css({borderColor: "#ebcb8b"});
79-
$errors.show(); iframe.hide();
87+
header.css({
88+
borderColor: "#ebcb8b"
89+
});
90+
$errors.show();
91+
iframe.hide();
8092
},
8193
"proxy-error": function(errors) {
8294
status.text("Could not proxy to content base target!");
8395
okness.text("Proxy error.");
8496
$errors.text("\n" + stripAnsi(errors.join("\n\n\n")) + "\n\n");
85-
header.css({borderColor: "#ebcb8b"});
86-
$errors.show(); iframe.hide();
97+
header.css({
98+
borderColor: "#ebcb8b"
99+
});
100+
$errors.show();
101+
iframe.hide();
87102
},
88103
close: function() {
89104
status.text("");
90105
okness.text("Disconnected.");
91106
$errors.text("\n\n\n Lost connection to webpack-dev-server.\n Please restart the server to reestablish connection...\n\n\n\n");
92-
header.css({borderColor: "#ebcb8b"});
93-
$errors.show(); iframe.hide();
107+
header.css({
108+
borderColor: "#ebcb8b"
109+
});
110+
$errors.show();
111+
iframe.hide();
94112
}
95113
};
96114

97115
newConnection(onSocketMsg);
98116

99117
iframe.load(function() {
100118
status.text("App ready.");
101-
header.css({borderColor: ""});
119+
header.css({
120+
borderColor: ""
121+
});
102122
iframe.show();
103123
});
104124

@@ -113,7 +133,9 @@ $(function() {
113133
iframe.show();
114134
} else {
115135
status.text("App updated. Reloading app...");
116-
header.css({borderColor: "#96b5b4"});
136+
header.css({
137+
borderColor: "#96b5b4"
138+
});
117139
try {
118140
var old = iframe[0].contentWindow.location + "";
119141
if(old.indexOf("about") == 0) old = null;

client/webpack.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
module.exports = {
22
module: {
3-
loaders: [
4-
{ test: /\.css$/, loader: "style!css" },
5-
{ test: /\.pug$/, loader: "pug?self" }
6-
]
3+
loaders: [{
4+
test: /\.css$/,
5+
loader: "style!css"
6+
}, {
7+
test: /\.pug$/,
8+
loader: "pug?self"
9+
}]
710
},
811
node: {
912
fs: "empty"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"scripts": {
5555
"prepublish": "webpack ./client/live.js client/live.bundle.js --color --config client/webpack.config.js -p && webpack ./client/index.js client/index.bundle.js --color --config client/webpack.config.js -p",
5656
"lint": "eslint bin lib test client/{index,live,webpack.config}.js",
57-
"beautify-lint": "beautify-lint lib/**.js bin/**.js",
58-
"beautify": "beautify-rewrite lib/**.js bin/**.js",
57+
"beautify-lint": "beautify-lint lib/**.js bin/**.js client/{index,live,webpack.config}.js",
58+
"beautify": "beautify-rewrite lib/**.js bin/**.js client/{index,live,webpack.config}.js",
5959
"travis": "npm run lint && npm run beautify-lint && node lib/Server.js"
6060
}
6161
}

0 commit comments

Comments
 (0)