-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #581
- Loading branch information
Showing
22 changed files
with
180 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# https | ||
# CLI - public | ||
|
||
NOTE: replace `<insert local ip>` with your local ip. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# https | ||
# CLI - stdin | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --stdin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Hot Module Reloading | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --open --hot | ||
``` | ||
|
||
With Hot Module Reloading we want to apply updates to the page without fully refreshing it. | ||
|
||
## What should happen | ||
|
||
The script should open `http://localhost:8080/`. In the app you should see "Does it work?" | ||
|
||
In your editor, go to `example.js`, and change "Does it work?" to "It works!" | ||
|
||
Open the devtools for the app, and you should see: | ||
|
||
``` | ||
[WDS] App updated. Recompiling... | ||
[WDS] App hot update... | ||
[HMR] Checking for updates on the server... | ||
[HMR] Updated modules: | ||
[HMR] - ./example.js | ||
[HMR] - ./hmr.js | ||
[HMR] App is up to date. | ||
``` | ||
|
||
Also verify that the text actually in the app actually changed to "It works!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("./hmr"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var myText = document.getElementById("mytext"); | ||
|
||
myText.textContent = "Does it work? yes"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require("./example"); | ||
|
||
if (module.hot) { | ||
module.hot.accept(function(err) { | ||
if (err) { | ||
console.error("Cannot apply hot update", err); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h1>Example: Hot Module Reloading</h1> | ||
<div id="mytext"></div> | ||
<script src="bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var webpack = require("webpack"); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: "./app.js", | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# https | ||
# host and port | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --open --port 5000 --host 0.0.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Node.js API - Middleware | ||
|
||
```shell | ||
node server.js | ||
``` | ||
|
||
Starts a webpack-dev-server setup via the Node API. Open `http://localhost:8080/` to go the app. | ||
|
||
## What should happen | ||
|
||
In the app you should see "It's working." | ||
|
||
In the CLI, you should see this for each refresh in the browser: | ||
|
||
``` | ||
Using middleware for / | ||
Using middleware for /bundle.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
document.write("It's working."); | ||
|
||
// This results in a warning: | ||
if(!window) require("./" + window + "parseable.js"); | ||
|
||
// This results in an error: | ||
// if(!window) require("test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
<h1>Example: Node.js API - Middleware</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var Webpack = require('webpack'); | ||
var WebpackDevServer = require("../../lib/Server"); | ||
var webpackConfig = require("./webpack.config"); | ||
|
||
var compiler = Webpack(webpackConfig); | ||
var server = new WebpackDevServer(compiler, { | ||
stats: { | ||
colors: true | ||
}, | ||
setup: function(app) { | ||
app.use(function(req, res, next) { | ||
console.log("Using middleware for " + req.url); | ||
next(); | ||
}); | ||
} | ||
}); | ||
|
||
server.listen(8080, "127.0.0.1", function() { | ||
console.log("Starting server on http://localhost:8080"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var path = require('path'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"], | ||
output: { | ||
filename: "bundle.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Node.js API - Simple | ||
|
||
```shell | ||
node server.js | ||
``` | ||
|
||
Starts a simple webpack-dev-server setup via the Node API. Open `http://localhost:8080/` to go the app. | ||
|
||
## What should happen | ||
|
||
In the app you should see "It's working." | ||
|
||
In `app.js`, uncomment the code that results in an error and save. This error should be visible in the CLI and devtools. | ||
|
||
Then, in `app.js`, uncomment the code that results in a warning. This warning should be visible in the CLI and devtools. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
document.write("It's working."); | ||
|
||
// This results in a warning: | ||
if(!window) require("./" + window + "parseable.js"); | ||
|
||
// This results in an error: | ||
// if(!window) require("test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
<h1>Example: Node.js API - Simple</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var Webpack = require('webpack'); | ||
var WebpackDevServer = require("../../lib/Server"); | ||
var webpackConfig = require("./webpack.config"); | ||
|
||
var compiler = Webpack(webpackConfig); | ||
var server = new WebpackDevServer(compiler, { | ||
stats: { | ||
colors: true | ||
} | ||
}); | ||
|
||
server.listen(8080, "127.0.0.1", function() { | ||
console.log("Starting server on http://localhost:8080"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var path = require('path'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: ["./app.js", "../../client/index.js?http://localhost:8080/"], | ||
output: { | ||
filename: "bundle.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Proxy: simple | ||
# Proxy: advanced | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --open | ||
|