diff --git a/README.md b/README.md index 842e071..2c52914 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,20 @@ ## Adding 3rd party libraries bower install jquery --save -Now to use jQuery in your frontend code, you'll need to add jQuery to **gulp-browserify** [config](https://github.com/deepak1556/gulp-browserify#browserify-shim). Your [compiler config](https://github.com/leonidas/gulp-project-template/blob/master/gulpfile.coffee#L17-L19) should be something like this: +Now to use jQuery in your frontend code, you'll need to add jQuery to "browser" and "browserify-shim" sections of your package.json. Your package.json should be something like this: - compileCoffee = (debug = false) -> - config = - debug: debug - transform: ['coffeeify'] - shim: - jquery: - path: './vendor/jquery/jquery.js' - exports: '$' + ... + + "browser": { + "jquery": "./vendor/jquery/dist/jquery.js" + }, + "browserify-shim": { + "jquery": "$" + }, + "browserify": { + "transform": [ "coffeeify", "browserify-shim" ] + } + ... Now your should be able to require jQuery in your coffee files @@ -45,6 +49,7 @@ Now your should be able to require jQuery in your coffee files ## Development guidelines * **public** - directory should be dedicated only to compiled/copied files from **src** - directory. It should be possible to delete directory completely and after **npm start** or **npm run build** everything should be as they were before the deletation. +* All backend dependencies should be installed with **npm**. Browser dependencies should be installed with **bower**. ## Enable LiveReload Install [LiveReload for Chrome](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en) diff --git a/gulpfile.coffee b/gulpfile.coffee index 65fe9f4..d1e9c51 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -14,13 +14,9 @@ livereload = require 'gulp-livereload' reloadServer = lr() compileCoffee = (debug = false) -> - config = - debug: debug - transform: ['coffeeify'] - bundle = gulp .src('./src/coffee/main.coffee', read: false) - .pipe(browserify(config)) + .pipe(browserify(debug: debug)) .pipe(rename('bundle.js')) bundle.pipe(uglify()) unless debug diff --git a/package.json b/package.json index e0cf1e7..5dcfed7 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,20 @@ "gulp-util": "~2.2.9", "gulp-stylus": "0.0.9", "gulp-jade": "~0.3.0", - "gulp-browserify": "~0.2.5", + "gulp-browserify": "~0.5.0", "node-static": "~0.7.3", "gulp-minify-css": "~0.2.0", "coffeeify": "~0.5.2", "tiny-lr": "0.0.5", "gulp-livereload": "~0.2.0", "bower": "~1.2.8", - "gulp": "~3.5.2" + "gulp": "~3.5.2", + "browserify-shim": "~3.3.1" + }, + + "browser": {}, + "browserify-shim": {}, + "browserify": { + "transform": [ "coffeeify", "browserify-shim" ] } }