Webpack now bundling all our app code
- We use import/export to indicate dependencies - Webpack makes sure everything loads in the correct order - We can remove all our additional script tags in index.html
This commit is contained in:
parent
2400d188ea
commit
2b11dd3624
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
@ -39,10 +39,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<img src="./assets/webpack.svg" />
|
<img src="./assets/webpack.svg" />
|
||||||
</body>
|
</body>
|
||||||
<script src="./src/app/alert.service.js"></script>
|
|
||||||
<script src="./src/app/component.service.js"></script>
|
|
||||||
<script src="./src/app/utils/inputs-are-valid.js"></script>
|
|
||||||
<script src="./src/app/utils/parse-inputs.js"></script>
|
|
||||||
<script src="./src/app/app.js"></script>
|
|
||||||
<script src="./dist/main.js"></script>
|
<script src="./dist/main.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class AlertService {
|
import { inputsAreValid } from "./utils/inputs-are-valid";
|
||||||
|
export class AlertService {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.errorBox = document.getElementById("error");
|
this.errorBox = document.getElementById("error");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const alertService = new AlertService();
|
import { inputsAreValid } from "./utils/inputs-are-valid";
|
||||||
const componentService = new ComponentService();
|
import { parseInputs } from "./utils/parse-inputs";
|
||||||
const run = (alertService, componentService) => {
|
export const run = (alertService, componentService) => {
|
||||||
alertService.hideErrors();
|
alertService.hideErrors();
|
||||||
|
|
||||||
componentService.onClick(() => {
|
componentService.onClick(() => {
|
||||||
@ -16,4 +16,3 @@ const run = (alertService, componentService) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
run(alertService, componentService);
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class ComponentService {
|
export class ComponentService {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.numberOneInput = document.getElementById("numberOne");
|
this.numberOneInput = document.getElementById("numberOne");
|
||||||
this.numberTwoInput = document.getElementById("numberTwo");
|
this.numberTwoInput = document.getElementById("numberTwo");
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
const inputsAreValid = (...input) => {
|
export const inputsAreValid = (...input) => {
|
||||||
return input.every(num => typeof num === "number" && !isNaN(num));
|
return input.every(num => typeof num === "number" && !isNaN(num));
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
const parseInputs = (...input) => {
|
export const parseInputs = (...input) => {
|
||||||
return input.map(str => parseInt(str));
|
return input.map(str => parseInt(str));
|
||||||
};
|
};
|
||||||
|
@ -1 +1,6 @@
|
|||||||
alert("HELLO FROM WEBPACK!");
|
import { run } from "./app/app";
|
||||||
|
import { AlertService } from "./app/alert.service";
|
||||||
|
import { ComponentService } from "./app/component.service";
|
||||||
|
const alertService = new AlertService();
|
||||||
|
const componentService = new ComponentService();
|
||||||
|
run(alertService, componentService);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user