JSJ - JavaScript Tools Fatigue State of JavaScript Build Tools
- Over reliance on plugins
- Out of date dependencies
- One more API to remember & debug
- Running different build tools from NPM
- Expected default for NodeJS apps
- Standardization across projects
- You already know it
{
"name": "mySecretApp",
"version": "1.0.0",
"description": "This solves all of the worlds problems",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Rob Tarr",
"license": "ISC"
}
- start
- test
Note: For things like Heroku, CircleCI, etc. they will look for these defaults.
scripts: {
"prestart": "...",
"start": "...",
"poststart": "..."
}
scripts: {
"premyTask": "...",
"myTask": "...",
"postmyTask": "..."
}
"scripts": {
"test": "node_modules/.bin/yourFancyNodeModule
}
"scripts": {
"test": "yourFancyNodeModule"
}
"scripts": {
"env": "env"
}
- CLI Tools
- Bash scripts
- JavaScript files
- Other build tools?!?!
"scripts": {
"start": "webpack -w"
}
watch.js
var chokidar = require('chokidar');
chokidar.watch('./data').on('all', (event, path) => {
// process data files
});
chokidar.watch('./templates').on('all', (event, path) => {
// compile HTML
});
package.json
"scripts": {
"start": "node scripts/watch.js"
}
"scripts": {
"build:js": "cat *.js > app.js"
}
"scripts": {
"start": "webpack"
}
"scripts": {
"test": "jasmine-node specs/*.js"
}
"scripts": {
"start": "webpack -p && npm run scss && node app.js"
}
#Pre & Post
"scripts": {
"pre": "npm run scss",
"start": "webpack -p",
"post": "node app.js"
}
"scripts": {
"start": "concurrently 'webpack -w' 'npm run scss' 'nodemon app.js' 'npm run test'"
"test": "jasmine-node specs/*.js --autotest --watch specs"
}
"scripts": {
"start": "node scripts/start.js"
}
let env = process.env.NODE_ENV;
const shell = require('shelljs');
if (env === 'production') {
console.log('Starting Production...');
shell.exec('webpack -p && npm run scss && node app.js');
} else {
console.log('Starting Development...');
shell.exec(`concurrently 'webpack -w' 'npm run scss' 'nodemon app.js' 'npm run test'`);
}
NOTE: Sure, this adds a small amoutn of complexity, but it's complexity that is entirely visible and familiar to me.
"scripts": {
"test": "jasmine-node specs/*.js"
"test:xunit": "npm run test -- --reporter xunit"
}
"scripts": {
"build": "webpack -p | hashmark 'assets/bundle.{hash}.js'"
"postbuild": "< ./assets/bundle.js hashmark './assets/bundle.{hash}.js'"
}
assets/
bundle.46732501c8b3255c87f0107620284485ec0095221017f194e3495abbd2f6b16a.js
"scripts": {
"test": "scripty",
"test:unit": "scripty",
"test:integration": "scripty"
}