Personal site of UI/UX developer Patrick Lewis
HTML JavaScript CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
libs/js
src
.editorconfig
.eslintignore
.eslintrc.js
.gitignore
CNAME
README.md
_config.yml
index.html
package.json
trace.html

README.md

Mountaindrawn.com

Personal website of UI/UX developer Patrick Lewis. Feel free to take and use anything you find useful. Build system based off the npm-build-boilerplate

To seamlessly deploy both master and gh-pages branch with 'git push'. Add this to your .git config [remote "origin"]

push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master

npm-build-boilerplate

A collection of packages that build a website using npm scripts.

List of packages used

autoprefixer, browser-sync, eslint, imagemin-cli, node-sass, onchange, npm-run-all, postcss-cli, svgo, svg-sprite-generator, uglify-js.

Many, many thanks go out to Keith Cirkel for his post and his useful CLI tools!

Using in your project

  • First, ensure that node.js & npm are both installed. If not, choose your OS and installation method from this page and follow the instructions.
  • Next, use your command line to enter your project directory.
    • If this a new project (without a package.json file), start by running npm init. This will ask a few questions and use your responses to build a basic package.json file. Next, copy the "devDependencies" object into your package.json.
    • If this is an existing project, copy the contents of "devDependencies" into your package.json.
  • Now, copy any tasks you want from the "scripts" object into your package.json "scripts" object.
  • Finally, run npm install to install all of the dependencies into your project.

You're ready to go! Run any task by typing npm run task (where "task" is the name of the task in the "scripts" object). The most useful task for rapid development is watch:all. It will start a new server, open up a browser and watch for any SCSS or JS changes in the src directory; once it compiles those changes, the browser will automatically inject the changed file(s)!

List of available tasks

clean

rm -f dist/{css/*,js/*,images/*}

Delete existing dist files

autoprefixer

postcss -u autoprefixer -r dist/css/*

Add vendor prefixes to your CSS automatically

scss

node-sass --output-style compressed -o dist/css src/scss

Compile Scss to CSS

lint

eslint src/js

"Lint" your JavaScript to enforce a uniform style and find errors

uglify

mkdir -p dist/js && uglifyjs src/js/*.js -m -o dist/js/app.js && uglifyjs src/js/*.js -m -c -o dist/js/app.min.js

Uglify (minify) a production ready bundle of JavaScript

imagemin

imagemin src/images/* -o dist/images

Compress all types of images

serve

browser-sync start --server --files 'dist/css/*.css, dist/js/*.js, **/*.html, !node_modules/**/*.html'

Start a new server and watch for CSS & JS file changes in the dist folder

build:css

npm run scss && npm run autoprefixer

Alias to run the scss and autoprefixer tasks. Compiles Scss to CSS & add vendor prefixes

build:js

npm run lint && npm run concat && npm run uglify

Alias to run the lint, concat and uglify tasks. Lints JS, combines src JS files & uglifies the output

build:images

npm run imagemin && npm run icons

Alias to run the imagemin and icons tasks. Compresses images, generates an SVG sprite from a folder of separate SVGs

build:all

npm run build:css && npm run build:js && npm run build:images

Alias to run all of the build commands

watch:css

onchange 'src/**/*.scss' -- npm run build:css

Watches for any .scss file in src to change, then runs the build:css task

watch:js

onchange 'src/**/*.js' -- npm run build:js

Watches for any .js file in src to change, then runs the build:js task

watch:images

onchange 'src/images/**/*' -- npm run build:images

Watches for any images in src to change, then runs the build:images task

watch:all

npm-run-all -p serve watch:css watch:js

Run the following tasks simultaneously: serve, watch:css & watch:js. When a .scss or .js file changes in src, the task will compile the changes to dist, and the server will be notified of the change. Any browser connected to the server will then inject the new file from dist

postinstall

npm run build:all && npm run watch:all

Runs watch:all after npm install is finished

Need help?

Feel free to create an issue, tweet me, or send me an email. I'd be glad to help where I can!