Skip to content

Commit 62ed77f

Browse files
author
Ashwin Hegde
committed
Merge pull request #7 from hegdeashwin/develop
Adds eg10 3rd party plugin integration
2 parents d26d6dd + 105dd20 commit 62ed77f

File tree

7 files changed

+36
-0
lines changed

7 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
|7|```webpack-dev-server```|webpack-dev-server is a development server, it binds a small express server on localhost:8080 which serves your static assets as well as the bundle|
1515
|8|```webpack```|Multiple entry files are allowed|
1616
|9|```webpack```|Code splitting and loading files on demand, Open browser and try ```localhost:8080``` see content-1 is loaded but not content-2, Now try execute ```localhost:8080/#load``` see content-1 and content-2 are both loaded|
17+
|10|```webpack```|Shows how to load 3rd-party plugins|

codes/example-10/content-1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "Content 1";

codes/example-10/content-2.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "Content 2";

codes/example-10/entry.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
console.log("Hello World");
2+
3+
console.log(require('./content-1.js'));
4+
5+
if(window.location.href.indexOf('load') !== -1 ) {
6+
console.log(require('./content-2.js'));
7+
}

codes/example-10/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Eg10: 3rd party plugins</title>
6+
</head>
7+
<body>
8+
<h1>Hello Webpack</h1>
9+
10+
<script type="text/javascript" src="bundle.js"></script>
11+
</body>
12+
</html>

codes/example-10/webpack.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
2+
3+
module.exports = {
4+
entry: './entry.js',
5+
output: {
6+
filename: 'bundle.js'
7+
},
8+
plugins: [
9+
new OpenBrowserPlugin({
10+
url: 'http://localhost:8080'
11+
})
12+
]
13+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"homepage": "https://github.com/hegdeashwin/learning-webpack#readme",
2424
"devDependencies": {
2525
"css-loader": "^0.23.0",
26+
"open-browser-webpack-plugin": "0.0.1",
2627
"style-loader": "^0.13.0"
2728
}
2829
}

0 commit comments

Comments
 (0)