Developers write software to make their lives easier
We use scaffolding tools (such as "rails new" or the create-react-app project) to quickly get a project started, or to see how a project works with all the pieces together
Although useful, scaffolding can constrain you to someone else's way of thinking. Critically analyze any scaffolding system you use for suitability!We're going to try out Yeoman a scaffolding tool for webapps
$ npm install -g yo
Now, run yo
from your terminal. What happens? Now, try running one of the many generator options!
$ mkdir [directory name]
$ cd [directory name]
$ yo [choose a generator]
all: clean build
clean:
rm -rf foo
build:
mkdir foo && cd foo && touch index.html
Each word with a colon can be run as a command with make. "all" is what runs by default.
What makes Make cool and revolutionary as build tooling is it's smart: it does the minimum amount of work necessary based on what changed. In our simple example, this won't happen, but for compiling, it's A+
Programming nowadays is putting blocks together well. Dependency management is how we make sure we get the blocks we meant to, every time.
"npm is the package manager for JavaScript and the world’s largest software registry" - npmjs.com
Yarn is an alternative to npm, and many of the commands map. It's fast and has some strong benefits.
Create a new directory and run "npm init"
{
"name": "intro-to-build-tools",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "GDI Philly",
"license": "MIT"
}
Use npm to install a package AND save it to our dependencies!
$ npm install --save dinosaur-fetcher
Tip! You can also use -S instead of --save!
const dino = require('dinosaur-fetcher');
console.log(dino.random());
The "scripts" section of package.json can be any word, and you can run with "npm run [word]"
Some words have default behaviors, such as "start" and "install", and npm has lots of details on that.
Edit package.json to look like:
"scripts": {
"test": "echo \"No tests yet!\"",
"start": "node index.js"
},
And run "npm start"
For a challenge, use a new word (ex. "build") and have it run any bash command! Don't forget "npm run"!We'll talk about two today:
Pass files through the processes that need to occur. How do you make a car on the assembly line?
var gulp = require('gulp');
gulp.task('default', function() {
gulp.src('./*.js')
.pipe(gulp.dest('dist'));
});
Webpack is a module bundler for web applications.
Webpack is smart. It understands lots of module definitions (CommonJS, AMD, ES 6 modules, etc.) and puts things together
Loaders are how webpack understands files - how you can 'require()' a CSS file, or an image file, even!
Plugins perform actions on "compilations" or "chunks" of bundled code, vs. on a per file basis like a loader
Let's make a basic webpack configuration!
Work through this article here
https://medium.com/@polakallen/wtf-is-webpack-b45460a49457
Making Sense of All the Frontend Build Tools
Article Here
Webpack Course