Skip to content

Instantly share code, notes, and snippets.

@marianoviola
Created March 8, 2017 16:40
Show Gist options
  • Save marianoviola/b7973372fbd052ed69053bf9b10bf8ee to your computer and use it in GitHub Desktop.
Save marianoviola/b7973372fbd052ed69053bf9b10bf8ee to your computer and use it in GitHub Desktop.
using `npm run` to build and watch with less and browserify

The package.json above expects .less files to be in style/, browser code to be in browser/, and static files to be in static/.

To watch the less and js files for development, do:

npm run watch

To build for production, do:

npm run build
{
"name": "my-app",
"version": "0.0.0",
"dependencies": {
"browserify": "~2.36.1",
"less": "~1.5.1"
},
"devDependencies": {
"watchify": "~0.4.1",
"catw": "~0.2.0"
},
"scripts": {
"watch-css": "catw -c 'lessc -' 'style/*.less' -o static/bundle.css -v",
"watch-js": "watchify browser/*.js -o static/bundle.js -dv",
"watch": "npm run watch-css & npm run watch-js",
"build-css": "catw -c 'lessc -' 'style/*.less' > static/bundle.css",
"build-js": "browserify browser/*.js > static/bundle.js",
"build": "npm run build-css && npm run build-js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment