Skip to content

Commit

Permalink
- install lodash and vanilla-tilt
Browse files Browse the repository at this point in the history
- code splitting usign prevent duplication (jokesService is not working)
  • Loading branch information
fnurrahmah125 committed Nov 2, 2023
1 parent 04bc74d commit b8ebdfb
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 15 deletions.
2 changes: 2 additions & 0 deletions test-webpack/output/242.c492344aa320d0f928e9.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test-webpack/output/hello.2a18999539550d47038f.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-webpack/output/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Belajar Webpack</title><script defer="defer" src="main.e4b7653cf02e192897ed.js"></script><script defer="defer" src="vendor.7aa7351566afe8df91ac.js"></script><link href="style.259cfe6f9f24f6511d67.css" rel="stylesheet"></head><body><img src="img/cat-d908827b839c650602c2.jpg" alt="image" class="cat-img"/><div class="row justify-content-center mt-5"><div class="col-4"><div class="card"><div class="card-header text-center"><h3>WPU Super App</h3></div><div class="card-body"><div class="alert alert-danger" role="alert" id="error">error!</div><h5 class="card-title">Kalkulator Sakti</h5><div class="input-group mb-3"><input class="form-control" placeholder="masukkan angka" id="operand1" autofocus required/> <span class="input-group-text">+</span> <input class="form-control" placeholder="masukkan angka" id="operand2" required/> <button class="btn btn-primary" type="button" id="tombol-tambah">Jumlahkan!</button></div><div class="card mt-3"><div class="card-body">Hasilnya adalah: <span id="hasil"></span></div></div></div><div class="card-footer text-center"><button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#jokesModal" id="jokes-receh">Jokes Receh!</button></div></div></div></div><div class="modal fade" id="jokesModal" tabindex="-1" aria-labelledby="jokesModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="jokesModalLabel">Joke Hari Ini 🤣</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body">...</div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button></div></div></div></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Belajar Webpack</title><script defer="defer" src="main.caaaf053892ab24b10e9.js"></script><script defer="defer" src="242.c492344aa320d0f928e9.js"></script><script defer="defer" src="vendor.c5d7e9c9df7760116072.js"></script><script defer="defer" src="hello.2a18999539550d47038f.js"></script><script defer="defer" src="shared.356e651d06d2a689e718.js"></script><link href="style.259cfe6f9f24f6511d67.css" rel="stylesheet"></head><body><img src="img/cat-d908827b839c650602c2.jpg" alt="image" class="cat-img" data-tilt/><div class="row justify-content-center mt-5"><div class="col-4"><div class="card"><div class="card-header text-center"><h3>WPU Super App</h3></div><div class="card-body"><div class="alert alert-danger" role="alert" id="error">error!</div><h5 class="card-title">Kalkulator Sakti</h5><div class="input-group mb-3"><input class="form-control" placeholder="masukkan angka" id="operand1" autofocus required/> <span class="input-group-text">+</span> <input class="form-control" placeholder="masukkan angka" id="operand2" required/> <button class="btn btn-primary" type="button" id="tombol-tambah">Jumlahkan!</button></div><div class="card mt-3"><div class="card-body">Hasilnya adalah: <span id="hasil"></span></div></div></div><div class="card-footer text-center"><button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#jokesModal" id="jokes-receh">Jokes Receh!</button></div></div></div></div><div class="modal fade" id="jokesModal" tabindex="-1" aria-labelledby="jokesModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="jokesModalLabel">Joke Hari Ini 🤣</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body">...</div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button></div></div></div></div></body></html>
1 change: 1 addition & 0 deletions test-webpack/output/main.caaaf053892ab24b10e9.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions test-webpack/output/main.e4b7653cf02e192897ed.js

This file was deleted.

2 changes: 2 additions & 0 deletions test-webpack/output/shared.356e651d06d2a689e718.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
2 changes: 0 additions & 2 deletions test-webpack/output/vendor.7aa7351566afe8df91ac.js

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions test-webpack/output/vendor.c5d7e9c9df7760116072.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions test-webpack/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.10.0"
},
"dependencies": {
"lodash": "^4.17.15",
"vanilla-tilt": "^1.8.1"
}
}
25 changes: 25 additions & 0 deletions test-webpack/src/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import _ from "lodash";

console.log("Hello from hello.js");

const mahasiswa = [
{
nama: "Test 1",
email: "test1@gmail.com",
jurusan: "test 1",
},
{
nama: "Test 2",
email: "test2@gmail.com",
jurusan: "test 2",
},
{
nama: "Test 3",
email: "test3@gmail.com",
jurusan: "test 3",
},
];

const mhs = _.find(mahasiswa, { nama: "Test 3" });

console.log(mhs);
6 changes: 5 additions & 1 deletion test-webpack/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require("./vendor");
import css from "./style.scss";
import _ from "lodash";

import { run } from "./app/app.js";
import { AlertService } from "./app/services/alert.service.js";
import { CalculatorService } from "./app/services/calculator.service.js";
Expand All @@ -10,3 +11,6 @@ const calculatorService = new CalculatorService();
const jokesService = new JokesService();

run(alertService, calculatorService, jokesService);

const text = _.toUpper("Hello from index.js");
console.log(text);
2 changes: 1 addition & 1 deletion test-webpack/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>

<body>
<img src="img/cat.jpg" alt="image" class="cat-img" />
<img src="img/cat.jpg" alt="image" class="cat-img" data-tilt />
<div class="row justify-content-center mt-5">
<div class="col-4">
<div class="card">
Expand Down
1 change: 1 addition & 0 deletions test-webpack/src/vendor.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import * as bootstrap from "bootstrap";
import VanillaTilt from "vanilla-tilt";
15 changes: 14 additions & 1 deletion test-webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ const path = require("path");

module.exports = {
entry: {
main: "./src/index.js",
main: {
import: "./src/index.js",
dependOn: "shared",
},
vendor: "./src/vendor.js",
hello: {
import: "./src/hello.js",
dependOn: "shared",
},
shared: "lodash",
},
optimization: {
splitChunks: {
chunks: "all",
},
},
plugins: [
new HtmlWebpackPlugin({
Expand Down

0 comments on commit b8ebdfb

Please sign in to comment.