Skip to content

Commit

Permalink
Merge pull request #9 from oneut/add_local_web_server_with_webpack_ex…
Browse files Browse the repository at this point in the history
…ample

Add local web server with webpack example
  • Loading branch information
oneut authored Mar 31, 2018
2 parents 321548b 47af69e commit ae70293
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/local-web-server-with-webpack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 1,27 @@
# Local Web Server with webpack Example

This is a example that monitors the standard output of webpack and performs Live Reload to the local web server.

## Doing
Live Reload
Source website is local web server.
Set webpack task.
Command
Execute webpack watch.
Watch stdouts.
`Entrypoint main = bundle.js`
If stdout matches, `lrp` fires Live Reload.
Set local web server task.
Command
Start local web server.
use [http-server](https://github.com/indexzero/http-server)

## Ready
```
npm install
```

## Start
```
lrp start
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions examples/local-web-server-with-webpack/lrp.yml
Original file line number Diff line number Diff line change
@@ -0,0 1,18 @@
proxy:
host: "localhost:9500"
source:
host: "localhost:8080"
tasks:
webpack:
commands:
watch:
execute: "npm run webpack:start"
watch_stdouts:
- "Entrypoint main = bundle.js"
local-web-server:
monitor:
paths:
- "./public/index.html"
commands:
http-server:
execute: "npm run hs:start -- -p 8080"
18 changes: 18 additions & 0 deletions examples/local-web-server-with-webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 1,18 @@
{
"name": "local-web-server",
"version": "1.0.0",
"description": "Live reload local web server",
"scripts": {
"hs:start": "hs",
"webpack:start": "webpack --watch --mode=development"
},
"author": "",
"license": "MIT",
"dependencies": {
"http-server": "^0.11.1"
},
"devDependencies": {
"webpack": "^4.4.1",
"webpack-cli": "^2.0.13"
}
}
6 changes: 6 additions & 0 deletions examples/local-web-server-with-webpack/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
<html>
<body>
Hello Local Web Server with webpack.
<script src="assets/bundle.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions examples/local-web-server-with-webpack/src/assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
alert("transpiled!");
7 changes: 7 additions & 0 deletions examples/local-web-server-with-webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 1,7 @@
module.exports = {
entry: "./src/assets/app.js",
output: {
path: __dirname "/public/assets",
filename: "bundle.js"
}
};

0 comments on commit ae70293

Please sign in to comment.