Skip to content

Commit d26d6dd

Browse files
author
Ashwin Hegde
committed
Merge pull request #6 from hegdeashwin/develop
Develop
2 parents 9342c5b + 6600bbe commit d26d6dd

32 files changed

+173
-37
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ logs
66
pids
77
*.pid
88
*.seed
9+
*.map
910

1011
# Directory for instrumented libs generated by jscoverage/JSCover
1112
lib-cov
@@ -15,7 +16,7 @@ lib-cov
1516

1617
# Compiled binary addons (http://nodejs.org/api/addons.html)
1718
build/Release
18-
bundle.js
19+
bundle*.js
1920

2021
# Dependency directory
2122
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Learning WEBPACK - MODULE BUNDLER
22

3-
|Example No.|Execution Command|Comments|
4-
|-----------|-----------------|--------|
5-
|1, 2| ```webpack entry.js bundle.js``` | |
6-
|3| |we need the ```css-loader``` to process CSS files. We also need the ```style-loader``` to apply the styles in the CSS file. They need to be installed locally, without ```-g```|
7-
|4|```webpack entry.js bundle.js --module-bind 'css=style!css'``` | if you are using ```bash``` then use single quotes in Command. Please see https://github.com/webpack/webpack/issues/1453 for more information|
8-
|5|```webpack``` **OR** ```webpack --progress --colors``` **OR** ```webpack --progress --colors --watch``` | |
9-
|6|```webpack-dev-server --progress --colors --watch```|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 |
3+
|Eg.No.|Execution Command|Comments|
4+
|------|-----------------|--------|
5+
|1|```webpack entry.js bundle.js```|Webpack will read entry.js file to build bundle.js|
6+
|2|```webpack entry.js bundle.js -p``` |```-p``` is used for bundle minification|
7+
|2|```webpack entry.js bundle.js -d```|```-d``` is used for bundle with source maps|
8+
|3|```webpack entry.js bundle.js --progress```|Know the progress of building the bundle|
9+
|3|```webpack entry.js bundle.js --colors```|Display text in colors|
10+
|4|```webpack entry.js bundle.js```|we need the ```css-loader``` to process CSS files. We also need the ```style-loader``` to apply the styles in the CSS file. They need to be installed locally, without ```-g```|
11+
|5|```webpack entry.js bundle.js --module-bind 'css=style!css'``` | This will simplify the CSS require path. Note: If you are using ```bash``` then use single quotes in Command. Please see https://github.com/webpack/webpack/issues/1453 for more information|
12+
|6|```webpack```|Webpack will read ```webpack.config.js``` from the root directory to build bundle.js|
13+
|7|```webpack --watch```|Will keep a watch on files to automatically rebuild the bundle|
14+
|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|
15+
|8|```webpack```|Multiple entry files are allowed|
16+
|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|

codes/example-1/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Example 1</title>
5+
<title>Eg1: initial bundle</title>
66
</head>
77
<body>
8+
<h1>Hello World</h1>
9+
810
<script type="text/javascript" src="bundle.js"></script>
911
</body>
1012
</html>

codes/example-2/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Example 2</title>
5+
<title>Eg2: building minified bundle</title>
66
</head>
77
<body>
8+
<h1>Hello World</h1>
9+
810
<script type="text/javascript" src="bundle.js"></script>
911
</body>
1012
</html>

codes/example-3/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log("Hello webpack");
1+
module.exports = "Hello webpack";

codes/example-3/entry.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
console.log("Hello World");
22

3-
require("!style!css!./style.css");
4-
5-
console.log(require("./content.js"));
3+
console.log(require('./content.js'));

codes/example-3/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Example 3</title>
5+
<title>Eg3: building bundle with source map</title>
66
</head>
77
<body>
8+
<h1>Hello World</h1>
9+
810
<script type="text/javascript" src="bundle.js"></script>
911
</body>
1012
</html>

codes/example-3/style.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

codes/example-4/entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
console.log("Hello World");
22

3-
require("./style.css");
3+
require("!style!css!./style.css");
44

55
console.log(require("./content.js"));

codes/example-4/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Example 4</title>
5+
<title>Eg4: CSS-Loader</title>
66
</head>
77
<body>
8+
<h1>Hello Webpack</h1>
9+
810
<script type="text/javascript" src="bundle.js"></script>
911
</body>
1012
</html>

0 commit comments

Comments
 (0)