Skip to content

Instantly share code, notes, and snippets.

@lancegliser
Last active October 12, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancegliser/8e537ad3925e5b09fca4088b733801d8 to your computer and use it in GitHub Desktop.
Save lancegliser/8e537ad3925e5b09fca4088b733801d8 to your computer and use it in GitHub Desktop.
NPM build scripts for building in place .min files: stylelint, cssnano, jshint, cssnano
**/*.min.js
/libraries
**/*.min.css
/libraries

Custom Assets

All custom development, stylesheets, etc should be placed into the section. Note that semantic versioning is required for all assets. See: http://semver.org/ for details.

Asset management build process

For performance reasons, linting is not performed during minficiation. It is your job as a developer to ensure you have turned on linting in your IDE for stylelint (css) and jshint (js).

Depedencies:

  1. Node.js installed on your machine
  2. Terminal access (through your IDE most likely)

Directions:

Once:

npm install

Every time you start work:

npm run watch:all
{
"name": "static-assets",
"version": "1.0.0",
"description": "A set of static assets and libraries consumed by various domain sites.",
"author": "Lance Gliser",
"browserslist": [
"last 2 versions"
],
"scripts": {
"lint:css": "stylelint assets/**/*.css",
"lint:js": "jshint assets",
"minify:css": "postcss assets/**/*.css !**/*min.css --dir assets --base assets --ext .min.css --use cssnano",
"minify:js": "uglifyjs-folder assets -p \"**/*.js,!**/*min.js\" -e -o assets",
"build:css": "npm run lint:css && npm run minify:css",
"build:css": "npm run minify:css",
"build:js": "npm run lint:js && npm run minify:js",
"build:js": "npm run minify:js",
"build:all": "npm run build:css && npm run build:js",
"watch:css": "onchange \"assets/**/*.css\" -e \"**/*.min.css\" -- npm run build:css",
"watch:js": "onchange \"assets/**/*.js\" -e \"**/*.min.js\" -- npm run build:js",
"watch:all": "npm-run-all -p watch:css watch:js",
"postinstall": "npm run build:all && npm run watch:all"
},
"devDependencies": {
"autoprefixer": "latest",
"browser-sync": "latest",
"stylelint": "latest",
"cssnano": "latest",
"mkdirp": "latest",
"npm-run-all": "latest",
"onchange": "latest",
"postcss-cli": "latest",
"jshint": "latest",
"uglify-js": "latest",
"uglifyjs-folder": "latest"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment