node-scripts v1.0.6
Node scripts
About
Opinionated scripts for node projects using:
Configuration
Package.json
Example scripts configuration in package.json:
"scripts": {
"clean": "node-scripts clean ./build ./coverage",
"lint": "node-scripts lint ./src ./test",
"test": "node-scripts test",
"test:watch": "node-scripts test:watch",
"test:cov": "node-scripts test:cov",
"build": "node-scripts build ./src ./build",
"start": "node-scripts start ./src/index.js",
"prepare": "node-scripts prepare"
}Example node-scripts configuration in package.json:
"node-scripts": {
"package": [
"name",
"version",
"bin",
"keywords",
"authors",
"license"
],
"dependencies": [
"lodash.map",
"lodash.reduce"
],
"copy": [
{ "src": "LICENSE", "dest": "LICENSE" },
{ "src": "README.md", "dest": "README.md" }
]
}Example jest configuration in package.json:
"jest": {
"testRegex": "(/test/.*\\.spec.js)$",
"collectCoverage": true,
"collectCoverageFrom": [ "**/src/**/*.js" ]
}.babelrc
Example .babelrc file:
{
"presets": [
[
"env",
{ "targets": { "node": "current" } }
]
],
"plugins": [
["transform-object-rest-spread", { "useBuiltIns": true }]
]
}.eslintrc
Example .eslintrc file:
{
"parser": "babel-eslint",
// Add rules...
}Scripts
Clean Script
"clean": "node-scripts clean ./build ./coverage",
Remove the path(s) passed as arguments.
Lint Script
"lint": "node-scripts lint ./src ./test",
Use ESLint to lint javascript in the path(s) passed as arguments.
Test Script
"test": "node-scripts test",
Use Jest to test javascript in the path(s) passed as arguments.
Start Script
"start": "node-scripts start ./src/index.js",
Use Babel Watch to start the app, using the javascript file passed passed as an argument as the entry point.
Build Script
"build": "node-scripts build ./src ./build",
or
"build": "node-scripts build ./src ./build --no-minify",
Use Babel/Webpack/UglifyJS to build and minify the app. This will add a #!/usr/bin/env node line to the top of the file.
The build script will generate a package.json file, based on the app's package.json file.
The keys to include can be configured in the package section of the node-scripts configuration.
Dependencies can be bundled by including them in dependencies section of the node-scripts configuration.
The generated package.json file will include all dependencies from the app's package.json file, except dependencies which have been bundled.
Artefacts which need to be copied to the build folder can be configured in the copy section of the node-scripts configuration.
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago