An example using npm package variables and Surge in an npm run script.
Deploy to Surge with an npm run script: npm run deploy
.
Use other keys within your package.json
file as part of your npm run script. Since you already have metadata like the URL of the project, in the package.json
, why not make it part of your run script too?
"scripts": {
"deploy": "surge --domain $npm_package_homepage"
}
You might even make the main
filed the source directory:
"script": {
"deploy": "surge --project $npm_package_main --domain $npm_package_homepage"
}
The variable-based approach was inspired by this tweet from @juice49.
Copyright © 2015 Chloi Inc.