Skip to content

Instantly share code, notes, and snippets.

@kucukharf
Forked from adamreisnz/package.json
Created October 15, 2019 13:56
Show Gist options
  • Save kucukharf/1ebe32251386106da903fae061a25397 to your computer and use it in GitHub Desktop.
Save kucukharf/1ebe32251386106da903fae061a25397 to your computer and use it in GitHub Desktop.
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
"private": true,
"repository": {
"type": "git",
"url": ""
},
"bugs": {
"url": ""
},
"engines": {
"node": ">=6.3.0",
"npm": ">=3.10.5"
},
"scripts": {
"//": " --- GENERAL ---",
"reinstall": "rimraf node_modules && npm cache clean && npm install",
"start": "parallelshell 'npm run serve' 'npm run watch'",
"//": " --- CSS --- ",
"css:dev": "node-sass src/scss/index.scss --output-style compressed > dist/css/app.css",
"css:prod": "node-sass src/scss/index.scss --output-style compressed | postcss -u autoprefixer -b 'last 2 versions' > dist/css/app.css",
"//": " --- JAVASCRIPT --- ",
"js:dev": "babel src/js | uglifyjs > dist/js/app.js",
"js:prod": "babel src/js | uglifyjs -m -c > dist/js/app.js",
"js:vendor": "uglifyjs vendor/*.js > dist/js/vendor.js",
"//": " --- BUILD (GENERIC) --- ",
"clean": "rimraf dist",
"mkdirs": "mkdir -p dist/js && mkdir -p dist/css",
"copy:assets": "cp -r assets/* dist",
"copy:html": "find src -name '*.html' -type f -exec cp {} dist \\;",
"copy": "npm run copy:assets && npm run copy:html",
"//": " --- BUILD (DEVELOPMENT) --- ",
"prebuild:dev": "npm run clean && npm run mkdirs && npm run copy",
"build:dev": "npm run css:dev && npm run js:dev && npm run js:vendor",
"//": " --- BUILD (PRODUCTION) --- ",
"prebuild:prod": "npm run clean && npm run mkdirs && npm run copy",
"build:prod": "npm run css:prod && npm run js:prod && npm run js:vendor",
"postbuild:prod": "npm run hash",
"//": " --- HASHING --- ",
"hash": "hashmark **/(app|vendor).* -d md5 -l 8 -c dist '{dir}/{name}.{hash}{ext}' | replaceinfiles -S -s dist/**/*.html",
"posthash": "rm dist/css/app.css && rm dist/js/app.js",
"//": " --- LINTING & TESTING --- ",
"lint": "eslint src/js --fix",
"pretest": "npm run lint",
"test": "npm run istanbul -s",
"posttest": "npm run coverage -s",
"istanbul": "istanbul cover ./node_modules/mocha/bin/_mocha 'test/**/*.spec.js'",
"coverage": "open -a 'Google Chrome' ./coverage/lcov-report/index.html",
"//": " --- SERVING --- ",
"kill": "lsof -n -i:8080 | grep LISTEN | awk '{print $2}' | xargs kill -9",
"preserve": "npm run build:dev && npm run kill",
"serve": "browser-sync start -s --files 'dist/**/*.(js|css|html)' --ss 'dist' --port 8080 --reload-debounce 500",
"//": " --- WATCHING --- ",
"watch:assets": "onchange 'assets/**/*' -- npm run copy:assets",
"watch:vendor": "onchange 'vendor/**/*.js' -- npm run js:vendor",
"watch:html": "onchange 'src/**/*.html' -- npm run copy:html",
"watch:css": "onchange 'src/**/*.scss' -- npm run css:dev",
"watch:js": "onchange 'src/**/*.js' -- npm run js:dev",
"watch": "parallelshell 'npm run watch:css' 'npm run watch:js' 'npm run watch:html' 'npm run watch:assets'",
"//": " --- DEPLOYMENT & ZIP --- ",
"postversion": "git push && git push --tags",
"predeploy": "npm run build:prod",
"deploy": "firebase deploy --project project-name",
"prezip": "npm run build:prod",
"zip": "cd dist && zip -r -X ../app.zip ."
},
"devDependencies": {
"autoprefixer": "^6.3.7",
"babel-cli": "^6.11.4",
"babel-preset-es2015": "^6.9.0",
"browser-sync": "^2.14.0",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"dirty-chai": "^1.2.2",
"eslint": "^3.2.2",
"firebase-tools": "^3.0.5",
"hashmark": "^3.1.0",
"istanbul": "^1.0.0-alpha.2",
"mocha": "^2.5.3",
"mocha-clean": "^1.0.0",
"node-sass": "^3.8.0",
"onchange": "^2.5.0",
"parallelshell": "^2.0.0",
"postcss-cli": "^2.5.2",
"replaceinfiles": "^1.1.4",
"rimraf": "^2.5.4",
"uglify-js": "^2.7.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment