Webpack & TypeScript Setup #2 - Webpack Installation

Net Ninja · Beginner ·🌐 Frontend Engineering ·6y ago

Key Takeaways

Installs Webpack for TypeScript

Full Transcript

alright then gang so I've already opened up vs code and I've got a brand new project a folder called web pack typescript nothing in there at the minute and the first thing I'm gonna do is create or initialize a new typescript project now to do that we say TS c and we need typescript installed globally on our computer in order to do this remember if you don't know how to do that check out the tutorial series all about typescript the link is down below and then double dash and in it and this initialize Azores with a typescript config file right here so inside this config file we can specify different options about how typescript is gonna work the only two things I'm gonna do is change the target property to es6 and that means that the output javascript that we're going to get at the end is going to follow along with the es6 specification and i want to say that the module system that we're going to use is going to be the es 2015 specification as well so that's all I'm going to do inside that config file the next thing I want to do is initialize a package.json file to keep track of all of our dependencies because we need to install a few dependencies for webpack so to do that I'm going to say NPM in it and then press ENTER and then down here I'm just going to enter through all of the different questions it's asking me right here the entry point will be indexed is enter through the rest that's absolutely fine you can fill these in if you wish but for me that's absolutely fine and now we get this package JSON file and whenever we're using NPM to install different packages we typically create this package JSON file first of all to keep track of those dependencies that we install so speaking of dependencies we want to install web pack as a dependency to this project and also a couple of other things as well so to do that we'll say NPM install and it's going to be web pack first of all we also want to install the web pack CLI and that's going to be how we interact with web pack via the command line interface then we want to also install TS loader and that is going to be something that we use later on as well so we want to save all of these to our dev dependencies so that the tracked inside package and to do that we can say - capital D and that saves them to the dev dependencies so webpack that package is going to be the core webpack package that ultimately compiles and bundles all of our code together the web pack CLI is going to be a tool that allows us to run web pack commands from the command line and the TS loader is a package that teaches web pack how to compile typescript into javascript and without it it wouldn't be able to do that so now we can see that we have a node modules folder and a package lock file right there as well now all of the dependencies we just installed are going to live inside this node modules folder we don't need to go in there and edit anything directly that's just where they live now this package lock file just locks in our dependencies for us we don't need to go into that file and do anything with that either but if we go into the package JSON file we can see now we have this property called dev dependencies and that is listing these three packages we just installed right here now you should also install typescript locally for your project as a dev dependency - for web pack to work with it properly even though we have it installed globally on our computer so to do that I'm going to say npm install typescript and then i'm going to add that as a dev dependency - press ENTER to install that local it for this project as a dev dependency so there we go that's that installed as well so this package JSON file is keeping track of all of the dependencies we use as well as store information about other things in our project as well such as the scripts and we'll come to that later on for now though we don't need to do anything more with it so now we've installed web pack and the other package is that we're going to need over the next couple of lessons now let's create a folder structure for our project so the first thing I'm going to do is create a new folder for the source files inside this project so all of our source code is going to live inside this folder right here the typescript files that I'm going to be creating so when I'm writing code for this project I'll only ever be writing code in files inside this source folder that is the source code now I also need to create another folder which is going to contain all of my final JavaScript any final CSS and HTML which will then be ready for deploying to the web so to do that I'm going to create another folder called public but you might also see this being called dist or something else but ultimately this folder will contain all of our final files and it will be the folder upload it to a web server to host the website now it should probably contain at least one HTML file since that is the backbone of a website so what I'm going to do is create a new file inside that called index dot HTML and inside here I'll say doc and tab and that creates me this mini boilerplate and what I'm actually going to do is just copy and paste all of the contents from my repo in here so you don't have to watch me write out HTML so let me paste that in dead-dead simple all this is is an h1 right here then a form with three labels and three inputs one for name one for email and one for age and we have a button at the bottom to submit it now I'm also going to change this title right here to webpack and type script like so and that is our HTML file done so that is pretty much it as far as the initial setup is concerned in fact I will just add one more file inside this source folder right here new file and we'll call this index dot es so remember es is the extension we use for typescript files and all of our typescript files are going to live inside this source folder right so the way this will work is as follows we're gonna write all of our code inside the source folder so anything typescript is going to go inside this source folder right here web pack is then later going to take those files and compile them into a single JavaScript bundle and it's then going to output that single bundle inside the public folder right here so we might have then something like bundled is inside this public folder and that is going to be then ready you deploy to the web and then the index file right here can later link to that bundle jeaious file so now I have the bare-bones set up in the next lesson we're going to create a web pack file to start this whole process

Original Description

🐱‍👤🐱‍👤 JOIN THE GANG - https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg/join ---------------------------------------- 🐱‍💻 🐱‍💻 My Udemy Courses: + Modern JavaScript - https://www.thenetninja.co.uk/udemy/modern-javascript + Vue JS & Firebase - http://www.thenetninja.co.uk/udemy/vue-and-firebase + D3.js & Firebase - https://www.thenetninja.co.uk/udemy/d3-and-firebase 🐱‍💻 🐱‍💻 Course Files: https://github.com/iamshaunjp/webpack-and-typescript 🐱‍💻 🐱‍💻 Other Related Free Courses: + HTML & CSS Crash Course - https://www.youtube.com/playlist?list=PL4cUxeGkcC9ivBf_eKCPIAYXWzLlPAm6G + Modern JavaScript - https://www.youtube.com/playlist?list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc + TypeScript Tutorial - https://www.youtube.com/playlist?list=PL4cUxeGkcC9gUgr39Q_yD6v-bSyMwKPUI 🐱‍💻 🐱‍💻 TypeScript Docs: https://www.typescriptlang.org/docs/home.html 🐱‍💻 🐱‍💻 The Net Ninja Community Boards: https://community.thenetninja.co.uk/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related AI Lessons

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →