Skip to content

Commit

Permalink
Merge pull request Lemoncode#21 from Lemoncode/master-front-end-ix-bu…
Browse files Browse the repository at this point in the history
…ndler-update

Master front end ix bundler update
  • Loading branch information
brauliodiez authored Nov 6, 2020
2 parents ca7bc3e + d67d931 commit 18c9b16
Show file tree
Hide file tree
Showing 113 changed files with 676 additions and 622 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions 03-bundling/01-webpack/01-zero-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack": "^5.3.1",
"webpack-cli": "^4.1.0"
}
}
2 changes: 1 addition & 1 deletion 03-bundling/01-webpack/01-zero-config/src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("Look ma! Zero config");
console.log("Look ma! Zero config");
25 changes: 11 additions & 14 deletions 03-bundling/01-webpack/02-boiler-plate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ _./package.json_
{
...
"devDependencies": {
+ "@babel/cli": "^7.1.2",
+ "@babel/core": "^7.1.2",
+ "@babel/preset-env": "^7.1.0",
+ "babel-loader": "^8.0.4",
+ "webpack": "^4.23.1",
+ "webpack-cli": "^3.1.2"
+ "@babel/cli": "^7.12.1",
+ "@babel/core": "^7.12.3",
+ "@babel/preset-env": "^7.12.1",
+ "babel-loader": "^8.1.0",
+ "webpack": "^5.3.1",
+ "webpack-cli": "^4.1.0"
}
}
```
Expand Down Expand Up @@ -127,9 +127,6 @@ _./webpack.config.js_
```javascript
module.exports = {
entry: ["./students.js"],
output: {
filename: "bundle.js"
}
};
```

Expand All @@ -140,9 +137,6 @@ _./webpack.config.js_
```diff
module.exports = {
entry: ['./students.js'],
output: {
filename: 'bundle.js',
},
+ module: {
+ rules: [
+ {
Expand Down Expand Up @@ -196,12 +190,15 @@ _./index.html_
<title>Webpack 4.x by sample</title>
</head>
<body>
Hello Webpack 4!
<script src="./dist/bundle.js"></script>
Hello Webpack!
<script src="./dist/main.js"></script>
</body>
</html>
```

> IMPORTANT: This is not the best way to include an HTML file and link it with webpack,
> we will learn how to do this in a proper way later on.
- Now we can click on the html file and see our small piece of code up and running.

> **Note down** this is not the optimal solution, in next steps we will proper generate
Expand Down
6 changes: 3 additions & 3 deletions 03-bundling/01-webpack/02-boiler-plate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Webpack 4.x by sample</title>
<title>Webpack by sample</title>
</head>
<body>
Hello Webpack 4!
<script src="./dist/bundle.js"></script>
Hello Webpack!
<script src="./dist/main.js"></script>
</body>
</html>
10 changes: 5 additions & 5 deletions 03-bundling/01-webpack/02-boiler-plate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.1.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack": "^5.3.1",
"webpack-cli": "^4.1.0"
}
}
11 changes: 4 additions & 7 deletions 03-bundling/01-webpack/02-boiler-plate/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
module.exports = {
entry: ["./students.js"],
output: {
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
}
loader: "babel-loader",
},
],
},
};
6 changes: 3 additions & 3 deletions 03-bundling/01-webpack/03-import/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Webpack 4.x by sample</title>
<title>Webpack by sample</title>
</head>
<body>
Hello Webpack 4!
<script src="./dist/bundle.js"></script>
Hello Webpack !
<script src="./dist/main.js"></script>
</body>
</html>
10 changes: 5 additions & 5 deletions 03-bundling/01-webpack/03-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.1.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"webpack": "^5.3.1",
"webpack-cli": "^4.1.0"
}
}
3 changes: 2 additions & 1 deletion 03-bundling/01-webpack/03-import/students.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAvg } from "./averageService";
import { getAvg } from './averageService';

// Let's use some ES6 features
const scores = [90, 75, 60, 99, 94, 30];
const averageScore = getAvg(scores);
const messageToDisplay = `average score ${averageScore}`;
Expand Down
11 changes: 4 additions & 7 deletions 03-bundling/01-webpack/03-import/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
module.exports = {
entry: ["./students.js"],
output: {
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
}
loader: "babel-loader",
},
],
},
};
7 changes: 3 additions & 4 deletions 03-bundling/01-webpack/04-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ npm install webpack-dev-server --save-dev
```diff
"scripts": {
- "start": "webpack --mode development"
+ "start": "webpack-dev-server --mode development --open",
+ "start": "webpack serve",
+ "build": "webpack --mode development"
},
```
Expand All @@ -53,7 +53,6 @@ npm install webpack-dev-server --save-dev
_dist_ folder, right now we will make a workaround, update the path on the index.html file for the _bundle.js_
file, in later samples we will learn a better way to reference the bundled files into HTML (using HTMLWebpackPlugin)


_index.html_

```diff
Expand All @@ -67,8 +66,8 @@ _index.html_
</head>
<body>
Hello Webpack 4!
- <script src="./dist/bundle.js"></script>
+ <script src="bundle.js"></script>
- <script src="./dist/main.js"></script>
+ <script src="main.js"></script>
</body>
</html>

Expand Down
6 changes: 3 additions & 3 deletions 03-bundling/01-webpack/04-server/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Webpack 4.x by sample</title>
<title>Webpack by sample</title>
</head>
<body>
Hello Webpack 4!
<script src="bundle.js"></script>
Hello Webpack !
<script src="main.js"></script>
</body>
</html>
15 changes: 8 additions & 7 deletions 03-bundling/01-webpack/04-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
"description": "In this sample we are going to setup a web project that can be easily managed by webpack.",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode development"
"start": "webpack serve",
"build": "webpack --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.1.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack": "^5.3.1",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
}
3 changes: 2 additions & 1 deletion 03-bundling/01-webpack/04-server/students.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAvg } from "./averageService";
import { getAvg } from './averageService';

// Let's use some ES6 features
const scores = [90, 75, 60, 99, 94, 30];
const averageScore = getAvg(scores);
const messageToDisplay = `average score ${averageScore}`;
Expand Down
11 changes: 4 additions & 7 deletions 03-bundling/01-webpack/04-server/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
module.exports = {
entry: ["./students.js"],
output: {
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
}
loader: "babel-loader",
},
],
},
};
17 changes: 9 additions & 8 deletions 03-bundling/01-webpack/05-output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
"description": "In this sample we are going to setup a web project that can be easily managed by webpack.",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode development"
"start": "webpack serve",
"build": "webpack --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.1.0",
"html-webpack-plugin": "^4.4.1",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"html-webpack-plugin": "^4.5.0",
"webpack": "^5.3.1",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
}
3 changes: 2 additions & 1 deletion 03-bundling/01-webpack/05-output/students.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAvg } from "./averageService";
import { getAvg } from './averageService';

// Let's use some ES6 features
const scores = [90, 75, 60, 99, 94, 30];
const averageScore = getAvg(scores);
const messageToDisplay = `average score ${averageScore}`;
Expand Down
15 changes: 6 additions & 9 deletions 03-bundling/01-webpack/05-output/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
entry: ["./students.js"],
output: {
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
loader: "babel-loader",
},
],
},
plugins: [
//Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: "index.html", //Name of file in ./dist/
template: "index.html", //Name of template in ./src
hash: true
})
]
hash: true,
}),
],
};
Loading

0 comments on commit 18c9b16

Please sign in to comment.