vhoang11 / INDIVIDUAL-ASSESSMENT-vocab-YOU-lary

0 stars 0 forks source link

Q2 - Individual Assessment: Vocab-YOU-lary

VIEW PROJECT INSTRUCTIONS

Topics

Get Started

  1. Clone your new repo to your local machine

Starting the Project

  1. Open the package.json file and change the name property to the name of your application, and author to your name.
  2. Rename the .sample.env file to .env file. The final file name should be .env
  3. From your command line, be in the root directory and run npm install OR npm i for short.
  4. To start your application, run npm start

If you see this, you are set to go!

lit-screen

NOTES:

Other Important Tidbits

Console messages

From this time forward, you will be expected to have a clean console in order for your assignments to be approved. This means that the use of console.log is acceptable (debugger is WAY better though) while developing, but will throw an error in your console like the image below, but all logs will have to be removed. You may use console.error and console.warn in your code however for messages. These need to all be removed before pushing to production unless they contain vital info for the user/developer.

notacceptable

Including Images with Webpack

If you have a folder of local images that you want to load into your code things get a little strange with webpack. Remember the only way webpack knows about assets is if they are imported into your javascript files. Even our CSS is not added until those files are imported into our javascript files. Below is some sample code for how to load a local image file into your project

import cat from './assets/cat.jpg';

let domString = `<img src=${cat} alt="picture of a cat"/>`;

document.getElementById('cat').innerHTMl = domString;

Importing CSS/SCSS

NOTE: We will be using SCSS files. They are used the same way your CSS files work, with some added benefits that we will discuss later.

Since Webpack is making the connection to the JS and CSS for us and we are no longer manually adding links or script tags to our HTML, we have to get our styles to the application some way...

Here is how we add our styles using webpack:

import '../styles/main.scss';

const init = () => {
  document.querySelector('#app').innerHTML = '<h1>HELLO! You are up and running!</h1>');
  console.log('YOU ARE UP AND RUNNING!');
};

init();

Deploying on Netlify

More Info and Resources on Webpack