Skip to content

Instantly share code, notes, and snippets.

@david-j-davis
Created March 26, 2017 17:56
Show Gist options
  • Save david-j-davis/3976016d4fadac19c42f8aa8fa29764b to your computer and use it in GitHub Desktop.
Save david-j-davis/3976016d4fadac19c42f8aa8fa29764b to your computer and use it in GitHub Desktop.
NPM scripting package.json and express server boilerplate
var express = require('express');
var app = express();
var port = process.env.PORT || 3000;
app.use(express.static(__dirname + '/public'));
app.listen(port, function (err) {
if (err) {
throw err;
}
console.log(`server is listening on ${port}...`);
});
{
"name": "",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"scripts": {
"scss": "node-sass --output-style expanded --indent-type tab --indent-width 1 -o public/css src/styles/",
"autoprefixer": "postcss --use autoprefixer -r public/css/styles.css public/css/styles.css",
"imagemin": "imagemin src/images public/img -p",
"js": "uglifyjs src/scripts/*.js -b -o public/js/main.js",
"server": "node index.js",
"serve": "browser-sync start --files 'public/**/*'",
"build:images": "npm run imagemin",
"build:css": "npm run scss && npm run autoprefixer",
"build:js": "npm run js",
"build:all": "npm run build:css && npm run build:images",
"watch:images": "onchange 'src/images' -- npm run build:images",
"watch:css": "onchange 'src/styles/**/*.scss' -- npm run build:css",
"watch:js": "onchange 'src/scripts/**/*.js' -- npm run build:js",
"watch:all": "parallelshell 'npm run server' 'npm run serve' 'npm run watch:css' 'npm run watch:images' 'npm run watch:js'",
"postinstall": "npm run watch:all"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
"browser-sync": "^2.11.1",
"imagemin-cli": "^2.1.0",
"node-sass": "^3.4.2",
"onchange": "^2.4.0",
"parallelshell": "^2.0.0",
"postcss-cli": "^2.5.1",
"uglify-js": "^2.7.4"
},
"dependencies": {
"babyparse": "^0.4.6",
"express": "^4.14.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment