GithubHelp home page GithubHelp logo

vigetlabs / gulp-rails-pipeline Goto Github PK

View Code? Open in Web Editor NEW
647.0 49.0 64.0 99 KB

Ditch the Rails Asset Pipeline and roll your own with Gulp

License: MIT License

Ruby 50.45% JavaScript 29.52% CSS 6.50% HTML 13.40% CoffeeScript 0.13%

gulp-rails-pipeline's Introduction

DEPRECATED: Use Blendid!

The work done in this repo has been rolled into a single dependency solution: Blendid!. You can set up your Rails project with the yarn run blendid -- init-rails command.

The Gulp Asset Pipeline on Rails

  • Leaves Sprockets and manifest files intact for use with gem installed assets
  • Transform and bundle CommonJS modules (js or coffee) with Browserify
  • Compile .sass/.scss with Libsass (node-sass through gulp-sass)
  • Autoprefix css
  • Optimize images (could be expanded to further process or resize images)
  • Compile an icon font + sass from a folder of SVGs
  • Full BrowserSync integration (the original Rails Asset Pipeline didn't work with live stylesheet injection)
  • Revision filenames in production for caching
  • Build assets on deploy with Heroku

Production Environment Demo (notice the revisioned asset filenames for caching)

This repo is only meant to be an example. You should fork and customize it with your own Rails setup and relevant Gulp tasks, or copy the relevant files into an existing project. To understand more about individual modules, read the documentation on their respective websites and repositories. Based on gulp-starter.

Running the Demo

Clone the repository

git clone https://github.com/vigetlabs/gulp-rails-pipeline.git

Enter into the directory and run bundle install

cd gulp-rails-pipeline
bundle install

Install javascript dependencies. Once npm install runs, the postinstall setting in package.json will run gulp build and do an initial build of your assets.

npm install

Start the rails server.

rails s

Run gulp and rejoice! This will start watching and recompiling files on the fly, as well as open a browser with BrowserSync running.

gulp

Try editing global.sass and watch how fast it reloads the css! Once you taste the speed of Libsass + BrowserSync, you'll never go back. Test out changing view code and javascript as well.

Asset File Structure

Asset File Structure

gulp/assets

This is where all your source files will live. Your source icons for icon fonts, sass files, js modules, and images. Anything that needs to get processed by Gulp. All assets are set up to compile to public/assets.

public/assets

The destination of your compiled and processed assets. The application.css and application.js manifest files in app/assets pull compiled code from this folder.

app/assets

The old default asset directory should only include manifest files, which are necessary if you need to require gem installed assets (e.g., jquery_ujs, turbolinks) with Sprockets. The manifest files pull in gem assets, as well as our compiled js and css files from /public/assets.

Rails setup notes:

config/application.rb

# Make public assets requireable in manifest files
config.assets.paths << Rails.root.join("public", "assets", "stylesheets")
config.assets.paths << Rails.root.join("public", "assets", "javascripts")

If you plan on continuing to use Sprockets to //require= gem assets, you'll include your compiled js and css files in the application.js and application.css manifests files. The snippet above tells Sprockets to look in our public/assets directories when searching for required files. With this implementation, you'll continue using the Rails javascript_include_tag and stylesheet_link_tag asset pipeline helpers to pull in your manifest files (and everything they require). If you end up not needing the pipeline at all, you can pull in your compiled css and js directly with the gulp_asset_path helper (see below) and regular html.

config/environments/development.rb

config.assets.debug = true
config.assets.digest = false

To fully take advantage of BrowserSync's live stylesheet injection, be sure to configure the two values above. Setting config.assets.debug to true tells Rails to output each individual file required in your application.js and application.css manifests, rather than concatenating them. This is the default setting in development. Setting config.assets.digest to false disables appending md5 hashes for caching with future Expires headers. With your individual files referenced and their file names unchanged, BrowserSync can reference and replace them properly as they get changed.

package.json

"scripts": {
  "postinstall": "gulp build"
},
"dependencies": {...}

After running npm install, Node will search the scripts object in package.json for postinstall, and will run the script if specified. gulp build compiles your assets. The build can be set up differently for different Rails environments. See below. A note about dependencies. Services like Heroku will ignore anything in devDependences, since it's technically a production environment. So be sure to put anything your build process needs to run in dependencies, NOT devDependencies.

gulp/tasks/build.js

// line 6
if(process.env.RAILS_ENV === 'production') tasks.push('rev');

If the RAILS_ENV is set to production, assets will be renamed with an appended md5 hash for caching with far future Expires headers, and any references in stylesheets or javascript files will be updated accordingly. For inline asset references in Rails Views, you can use the following asset helper.

app/helpers/application_helper.rb

def gulp_asset_path(path)
  path = REV_MANIFEST[path] if defined?(REV_MANIFEST)
  "/assets/#{path}"
end

Because we're storing our assets outside of the Rails Asset Pipeline, we need to re-implement the asset_path path helper as gulp_asset_path to reference un-hashed files in development, and the cacheable hashed versions of the files in production. This goes for other Rails Asset Pipeline helpers, such as <%= image_tag, 'asset.png' %>. Instead, use <img src="<%= gulp_asset_path('asset.png') %>">.

config/initializers/rev_manifest.rb

rev_manifest_path = 'public/assets/rev-manifest.json'

if File.exist?(rev_manifest_path)
  REV_MANIFEST = JSON.parse(File.read(rev_manifest_path))
end

You'll notice this constant referenced in the gulp_asset_path helper above. The gulp/tasks/rev.js that gets run in production outputs a rev-manifest.json file, mapping the original filenames to the revisioned ones. If that file exists when the app starts, the hashed filenames are used. If it doesn't exist, the filename references remain unchanged.

Deploying

To avoid git messiness and redundant rebases and merge conflicts, it's usually a good idea to .gitignore your compiled assets. This means you'll have to have them compile as part of your deploy process. In short, you'll need to ensure the following:

  1. Node is installed
  2. npm install runs
  3. gulp build runs on postinstall (specified in package.json)

These steps must complete before starting the Rails server.

Heroku

Heroku makes deploying SUPER easy, but there are a couple of things you'll need to do to get this running.

Since we're using Ruby (to run Rails) AND Node (to compile our assets with Gulp) in our setup, we need both running on our server. Heroku will automatically detect ONE of these at a time based on the presense of a Gemfile or package.json, but to get both running simultaneously, we need to specify multiple buildpacks in the order we want.

heroku buildpacks                     # view current buildpacks
heroku buildpacks:clear               # clear current buildpacks, if necessary
heroku buildpacks:add heroku/nodejs   # add the buildpacks we want ...
heroku buildpacks:add heroku/ruby     # ... in the order we want them

Now, when we deploy to Heroku, first npm install will run, then our postinstall script specified in package.json, and then bundle install will run.

Take note of the following:

  #production.rb line 25
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

Heroku requires config.serve_static_files to be enabled, so be sure to either add RAILS_SERVE_STATIC_FILES as a config var in your Heroku settings, or manually set this to true in your production.rb file.

Capistrano

All we need to do is add a task to run npm install before we compile the assets.

The example below shows an example of using nvm (node version manager) to use the specified node version for your application.

# ./config/deploy.rb

before "deploy:assets:precompile", "deploy:npm_install"

namespace :deploy do
  desc "Run npm install"
  task :npm_install do
    invoke_command "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && npm install'"
  end
end

Original Blog Post: viget.com/extend/gulp-rails-asset-pipeline


Code At Viget

Visit code.viget.com to see more projects from Viget.

gulp-rails-pipeline's People

Contributors

adunkman avatar arzatskis avatar chadwhitacre avatar greypants avatar limeblast avatar mackermedia avatar nemild avatar rowanoulton avatar yanthefawn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-rails-pipeline's Issues

Require JS files similar to require_tree

I have already been trying to get a working gulp-rails-pipeline for several days now and am stuck with a beginners question.

Let's say I have two JS models:

# javascripts/models/monkey.js.coffee
class App.Models.Monkey
  constructor: (@name) ->
    # do some setup

and

# javascripts/models/zoo.js.coffee
class App.Models.Zoo
  constructor: () ->
    monkey = new App.Models.Monkey("Charley")
    # ...

If I use Rails Sprockets I can simply add //= require_tree ./models to my application.js. Then I have access to App.Models.Monkey from within App.Models.Zoo out of the box (see example on top). Plain and simple!

Now gulp-rails-pipeline inspired me to ditch the Rails Asset Pipeline.

My question: How can I access my existing JavaScript classes within their namespace so that I can e.g. call new App.Models.Monkey("Charley") from App.Models.Zoo? (see the example on top)

Is there something simliar to require_tree for browserify? Is there something which allows me to simply leave all files as they are, bundle them to one big JS file AND references to e.g. App.Models.Monkey will somehow still magically work?

If not so: Is there some helper which can magically turn all of my classes into RequireJS modules?

Or do I need to turn all of my Models, Controllers, Routers, Views... into RequireJS modules manually (which will result in adding many module.exports and require statements)?

Any help would be highly appreciated. :)

Issue after upgrading to rails 4.2.3 and ruby 2.2.2

After upgrading to rails 4.2.3 and ruby 2.2.2 I am seeing the following error.

Missing error handler on `socket`.
Error: Cannot find module '/Users/project-name/node_modules/browser-sync-ui/node_modules/weinre/lib/utils.js'
  at Function.Module._resolveFilename (module.js:336:15)
  at Function.Module._load (module.js:278:25)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at enableWeinre (/Users/project-name/node_modules/browser-sync-ui/lib/plugins/remote-debug/weinre.js:166:20)
  at toggleWeinre (/Users/project-name/node_modules/browser-sync-ui/lib/plugins/remote-debug/weinre.js:105:25)
  at Object.methods.toggle (/Users/project-name/node_modules/browser-sync-ui/lib/plugins/remote-debug/weinre.js:50:13)
  at [object Object].methods.event (/Users/project-name/node_modules/browser-sync-ui/lib/plugins/remote-debug/weinre.js:53:33)
  at [object Object].UI.delegateEvent (/Users/project-name/node_modules/browser-sync-ui/lib/UI.js:111:29)
  at Socket.<anonymous> (/Users/project-name/node_modules/browser-sync-ui/lib/async.js:197:20)
  at Socket.emit (events.js:107:17)
  at Socket.onevent (/Users/project-name/node_modules/socket.io/lib/socket.js:330:8)
  at Socket.onpacket (/Users/project-name/node_modules/socket.io/lib/socket.js:290:12)
  at Client.ondecoded (/Users/project-name/node_modules/socket.io/lib/client.js:193:14)
  at Decoder.Emitter.emit (/Users/project-name/node_modules/component-emitter/index.js:134:20)
  at Decoder.add (/Users/project-name/node_modules/socket.io-parser/index.js:247:12)
  at Client.ondata (/Users/project-name/node_modules/socket.io/lib/client.js:175:18)
  at Socket.emit (events.js:107:17)
  at Socket.onPacket (/Users/project-name/node_modules/engine.io/lib/socket.js:99:14)
  at WebSocket.emit (events.js:129:20)
  at WebSocket.Transport.onPacket (/Users/project-name/node_modules/engine.io/lib/transport.js:91:8)
  at WebSocket.Transport.onData (/Users/project-name/node_modules/engine.io/lib/transport.js:102:8)
  at WebSocket.onData (/Users/project-name/node_modules/engine.io/lib/transports/websocket.js:75:30)
  at WebSocket.emit (events.js:110:17)
  at Receiver.ontext (/Users/project-name/node_modules/ws/lib/WebSocket.js:797:10)
  at /Users/project-name/node_modules/ws/lib/Receiver.js:473:18
  at /Users/project-name/node_modules/ws/lib/Receiver.js:357:7
  at /Users/project-name/node_modules/ws/lib/PerMessageDeflate.js:217:5
  at afterWrite (_stream_writable.js:361:3)
  at onwrite (_stream_writable.js:352:7)
  at WritableState.onwrite (_stream_writable.js:105:5)
  at afterTransform (_stream_transform.js:99:5)
  at TransformState.afterTransform (_stream_transform.js:74:12)
  at Zlib.callback (zlib.js:611:5)

Not sure where to start to fix, have you seen this error before?

Icon fonts not working

Hey guys, I just ran through the instructions for installing, and everything seems to load fine except for the icon fonts. When I inspect one of the icons, I'm seeing what appears to be some kind of encoding failure for the 'content' css property? See below

.icon.-twitter:before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
content: "";

Any suggestions? Thanks in advance!

Rails 4.2.1 + Sprockets 3.0.2 breaks browserSync

On a recent project I noticed that rails was adding ".self.(css|js)" to asset tags, which browsersync can't handle. I wasn't sure if this was just my project so I tested with this repo. I also made some very minor changes to get it working on my system (like updating browsersync version). This is with node 0.12.2 and running npm update/bundle update.

The included tags:

<link rel="stylesheet" media="screen" href="/assets/global.self.css?body=1" />\n
<link rel="stylesheet" media="screen" href="/assets/application.self.css?body=1" />\n
<script src="/assets/jquery.self.js?body=1"></script>\n
<script src="/assets/jquery_ujs.self.js?body=1"></script>\n
<script src="/assets/turbolinks.self.js?body=1"></script>\n
<script src="/assets/global.self.js?body=1"></script>\n
<script src="/assets/application.self.js?body=1"></script>

My git diff:

diff --git a/Gemfile b/Gemfile
index 7c0a052..6457fff 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,10 +1,10 @@
source 'https://rubygems.org'

-gem 'rails', '4.2.0'
+gem 'rails', '4.2.1'
 gem 'sass-rails', '~> 5.0'
 gem 'uglifier', '>= 1.3.0'
 gem 'coffee-rails', '~> 4.1.0'
 gem 'jquery-rails'
 gem 'turbolinks'
 gem 'sqlite3', group: :development
-gem 'pg', group: :production # For heroku
+# gem 'pg', group: :production # For heroku
diff --git a/Gemfile.lock b/Gemfile.lock
index e42c4c0..2c5286e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,36 +1,36 @@
 GEM
   remote: https://rubygems.org/
   specs:
-    actionmailer (4.2.0)
-      actionpack (= 4.2.0)
-      actionview (= 4.2.0)
-      activejob (= 4.2.0)
+    actionmailer (4.2.1)
+      actionpack (= 4.2.1)
+      actionview (= 4.2.1)
+      activejob (= 4.2.1)
       mail (~> 2.5, >= 2.5.4)
       rails-dom-testing (~> 1.0, >= 1.0.5)
-    actionpack (4.2.0)
-      actionview (= 4.2.0)
-      activesupport (= 4.2.0)
-      rack (~> 1.6.0)
+    actionpack (4.2.1)
+      actionview (= 4.2.1)
+      activesupport (= 4.2.1)
+      rack (~> 1.6)
       rack-test (~> 0.6.2)
       rails-dom-testing (~> 1.0, >= 1.0.5)
       rails-html-sanitizer (~> 1.0, >= 1.0.1)
-    actionview (4.2.0)
-      activesupport (= 4.2.0)
+    actionview (4.2.1)
+      activesupport (= 4.2.1)
       builder (~> 3.1)
       erubis (~> 2.7.0)
       rails-dom-testing (~> 1.0, >= 1.0.5)
       rails-html-sanitizer (~> 1.0, >= 1.0.1)
-    activejob (4.2.0)
-      activesupport (= 4.2.0)
+    activejob (4.2.1)
+      activesupport (= 4.2.1)
       globalid (>= 0.3.0)
-    activemodel (4.2.0)
-      activesupport (= 4.2.0)
+    activemodel (4.2.1)
+      activesupport (= 4.2.1)
       builder (~> 3.1)
-    activerecord (4.2.0)
-      activemodel (= 4.2.0)
-      activesupport (= 4.2.0)
+    activerecord (4.2.1)
+      activemodel (= 4.2.1)
+      activesupport (= 4.2.1)
       arel (~> 6.0)
-    activesupport (4.2.0)
+    activesupport (4.2.1)
       i18n (~> 0.7)
       json (~> 1.7, >= 1.7.7)
       minitest (~> 5.1)
@@ -41,15 +41,14 @@ GEM
     coffee-rails (4.1.0)
       coffee-script (>= 2.2.0)
       railties (>= 4.0.0, < 5.0)
-    coffee-script (2.3.0)
+    coffee-script (2.4.1)
       coffee-script-source
       execjs
-    coffee-script-source (1.9.0)
+    coffee-script-source (1.9.1.1)
     erubis (2.7.0)
-    execjs (2.3.0)
-    globalid (0.3.2)
+    execjs (2.5.2)
+    globalid (0.3.5)
       activesupport (>= 4.1.0)
-    hike (1.2.3)
     i18n (0.7.0)
     jquery-rails (4.0.3)
       rails-dom-testing (~> 1.0)
@@ -62,64 +61,59 @@ GEM
       mime-types (>= 1.16, < 3)
     mime-types (2.4.3)
     mini_portile (0.6.2)
-    minitest (5.5.1)
-    multi_json (1.10.1)
+    minitest (5.6.0)
     nokogiri (1.6.6.2)
       mini_portile (~> 0.6.0)
-    pg (0.18.1)
     rack (1.6.0)
     rack-test (0.6.3)
       rack (>= 1.0)
-    rails (4.2.0)
-      actionmailer (= 4.2.0)
-      actionpack (= 4.2.0)
-      actionview (= 4.2.0)
-      activejob (= 4.2.0)
-      activemodel (= 4.2.0)
-      activerecord (= 4.2.0)
-      activesupport (= 4.2.0)
+    rails (4.2.1)
+      actionmailer (= 4.2.1)
+      actionpack (= 4.2.1)
+      actionview (= 4.2.1)
+      activejob (= 4.2.1)
+      activemodel (= 4.2.1)
+      activerecord (= 4.2.1)
+      activesupport (= 4.2.1)
       bundler (>= 1.3.0, < 2.0)
-      railties (= 4.2.0)
+      railties (= 4.2.1)
       sprockets-rails
     rails-deprecated_sanitizer (1.0.3)
       activesupport (>= 4.2.0.alpha)
-    rails-dom-testing (1.0.5)
+    rails-dom-testing (1.0.6)
       activesupport (>= 4.2.0.beta, < 5.0)
       nokogiri (~> 1.6.0)
       rails-deprecated_sanitizer (>= 1.0.1)
-    rails-html-sanitizer (1.0.1)
+    rails-html-sanitizer (1.0.2)
       loofah (~> 2.0)
-    railties (4.2.0)
-      actionpack (= 4.2.0)
-      activesupport (= 4.2.0)
+    railties (4.2.1)
+      actionpack (= 4.2.1)
+      activesupport (= 4.2.1)
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
     rake (10.4.2)
-    sass (3.4.11)
-    sass-rails (5.0.1)
+    sass (3.4.13)
+    sass-rails (5.0.3)
       railties (>= 4.0.0, < 5.0)
       sass (~> 3.1)
       sprockets (>= 2.8, < 4.0)
       sprockets-rails (>= 2.0, < 4.0)
       tilt (~> 1.1)
-    sprockets (2.12.3)
-      hike (~> 1.2)
-      multi_json (~> 1.0)
+    sprockets (3.0.2)
       rack (~> 1.0)
-      tilt (~> 1.1, != 1.3.0)
     sprockets-rails (2.2.4)
       actionpack (>= 3.0)
       activesupport (>= 3.0)
       sprockets (>= 2.8, < 4.0)
     sqlite3 (1.3.10)
     thor (0.19.1)
-    thread_safe (0.3.4)
+    thread_safe (0.3.5)
     tilt (1.4.1)
     turbolinks (2.5.3)
       coffee-rails
     tzinfo (1.2.2)
       thread_safe (~> 0.1)
-    uglifier (2.7.0)
+    uglifier (2.7.1)
       execjs (>= 0.3.0)
       json (>= 1.8.0)

@@ -129,8 +123,7 @@ PLATFORMS
 DEPENDENCIES
   coffee-rails (~> 4.1.0)
   jquery-rails
-  pg
-  rails (= 4.2.0)
+  rails (~> 4.2.0)
   sass-rails (~> 5.0)
   sqlite3
   turbolinks
diff --git a/package.json b/package.json
old mode 100644
new mode 100755
index 0958cb5..b447a1c
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
     ]
   },
   "dependencies": {
-    "browser-sync": "~1.3.6",
+    "browser-sync": "^2.4.0",
     "browserify": "^8.0.2",
     "coffeeify": "~0.7.0",
     "del": "^1.1.1",

Assets not updating on Heroku

After the initial deployment of this example repo to Heroku, making further edits to the Gulp Sass assets and re-deploying seems to have no impact on the production css. I am able to purge the Heroku repo cache (using: https://github.com/heroku/heroku-repo) and then force another deployment to see the updates but this shouldn't be required. It seems the assets being built to /public/assets are part of the compiled slug and don't get updated unless the slug gets re-compiled.

Navigating directly to my example's assets/stylesheets/global.css file on Heroku, I can see that the styles mirror what was present on the initial deployment and not what the updated Gulp build should reflect.

Some questions and feature requests

Hi @greypants,

Your gem looks pretty cool, but I have some questions.

  • Does it supports *.js.erb files or at least *.js.ejs files?
  • Do you plan to support source mapping?

Cheers,
Nowhere Man

Serving assets from CDN

Is it possible to precompile assets and serve them from a CDN instead? I've been using asset_sync with the default rails pipeline and it's been working great.

Use gulp_asset_path in scss

I'm wondering how to link images or fonts in scss.

Is there an easy way to get the gulp_asset_path working in scss ?

Chrome devtools live editing

Does this support live editing through Chrome devtools? Steps I've taken:

  • Clone & bundle install & npm install & rails s & gulp.
  • Observe that source mappings work correctly (global.sass shows up in the devtools instead of global.css).
  • Workspace mappings (http://localhost:3001/source/global.sass -> file:///Users/halil/Code/test/gulp-rails-pipeline/gulp/assets/stylesheets/global.sass).
  • Click and edit some CSS on the dev toolbar.

Results:

  • Browser sync fires before I finish my edit and global.sass is converted to global.css (video) .
  • Changes aren't synced to global.sass.

Expected:

  • global.sassis modified.

PS: Thanks for your efforts.

How to get process.env.RAILS_ENV?

Hi,
thanks for your repo, very nice work!

I only have problem with process.env.RAILS_ENV, as it's always undefined. I guess you must be using some Rails code to set this, maybe .env file?

Thanks

Access sass mixins defined in gems

I used gulp-rails-pipeline to ditch the Rails Asset pipeline of an existing project. Now when running gulp build I get the following error:

gulp-notify: [Compile Error] Error in plugin 'gulp-sass'
Message: no mixin named panel

The mixin panel is part of the gem foundation-rails.
It is defined in the file foundation/components/panels which I import in /app/assets/stylesheets/application.css.scss:

/*
 * Pull compiled from /public/assets/stylesheets
 *= require global
 */
@import 'foundation/components/panels';

My file /gulp/assets/stylesheets/framework_and_overrides.scss basically is:

.authform form {
  @include panel();
}

How can I solve the gulp-sass error? What is the correct way to access mixins which are provided by a Rails gem from my scss files which are managed by gulp? Thanks! :)

Doesn't compile image-url sprockets helper

I cloned the project, installed gems/npm packages, compiled assets and opened http://localhost:3000/

I see the following in my browser:
screen shot 2016-03-09 at 1 28 41 pm

When I open the compiled public/assets/stylesheets/global.css I see

body {
  background: #dd3435 image-url("gulp.png");
  font-family: sans-serif; }

which is an invalid CSS rule. When I fix image-url to url manually and open the page again I see the following

screen shot 2016-03-09 at 1 32 14 pm

I could change the background rule in the global.sass to

background: #dd3435 url('gulp.png')

but seems that it won't work in the production because of the digest in the image filename

How can we fix this issue? Do you have any ideas?

Add tests and contrib guidelines

To start, I can set up Travis CI and just ensure that the gulp tasks successfully complete. But beyond that,
I'm not sure the best way to write tests that ensure more granular things are building properly.

Having trouble deploying to Heroku

Hi,

So I tried to deploy to heroku following the instructions specified, but got the following error:

Counting objects: 667, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (470/470), done.
Writing objects: 100% (667/667), 344.58 KiB | 0 bytes/s, done.
Total 667 (delta 278), reused 392 (delta 148)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/ddollar/heroku-buildpack-multi.git... done
remote: -----> Multipack app detected
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
remote: =====> Detected Framework: Node.js
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  0.10.36
remote:        engines.npm (package.json):   2.3.0
remote:
remote:        Downloading and installing node 0.10.36...
remote:        Downloading and installing npm 2.3.0 (replacing version 1.4.28)...
remote:
remote: -----> Restoring cache
remote:        Skipping cache restore (new runtime signature)
remote:
remote: -----> Building dependencies
remote:        Pruning any extraneous modules
remote:        Installing node modules (package.json)
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
remote:        > node index.js
remote:
remote:        ✔ pre-build test passed successfully!
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
remote:        > node index.js
remote:
remote:        ✔ pre-build test passed successfully!
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin
remote:        > node index.js
remote:
remote:        ✔ pre-build test passed successfully!
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin
remote:        > node index.js
remote:
remote:        ✔ pre-build test passed successfully!
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate
remote:        > node-gyp rebuild
remote:
remote:        make: Entering directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build'
remote:        CXX(target) Release/obj.target/validation/src/validation.o
remote:        SOLINK_MODULE(target) Release/obj.target/validation.node
remote:        SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
remote:        COPY Release/validation.node
remote:        make: Leaving directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build'
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil
remote:        > node-gyp rebuild
remote:
remote:        make: Entering directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil/build'
remote:        CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
remote:        SOLINK_MODULE(target) Release/obj.target/bufferutil.node
remote:        SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
remote:        COPY Release/bufferutil.node
remote:        make: Leaving directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil/build'
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil
remote:        > node-gyp rebuild
remote:
remote:        make: Entering directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil/build'
remote:        CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
remote:        SOLINK_MODULE(target) Release/obj.target/bufferutil.node
remote:        SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
remote:        COPY Release/bufferutil.node
remote:        make: Leaving directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil/build'
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate
remote:        > node-gyp rebuild
remote:
remote:        make: Entering directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate/build'
remote:        CXX(target) Release/obj.target/validation/src/validation.o
remote:        SOLINK_MODULE(target) Release/obj.target/validation.node
remote:        SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
remote:        COPY Release/validation.node
remote:        make: Leaving directory `/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate/build'
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-sass/node_modules/node-sass/node_modules/cross-spawn/node_modules/spawn-sync
remote:        > node postinstall
remote:
remote:        Installing native dependencies (this may take up to a minute)
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-sass/node_modules/node-sass
remote:        > node scripts/install.js
remote:
remote:        Binary downloaded and installed at /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-11/binding.node
remote:
remote:        > [email protected] postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-sass/node_modules/node-sass
remote:        > node scripts/build.js
remote:
remote:        ` /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-11/binding.node ` exists.
remote:        testing binary.
remote:        Binary is fine; exiting.
remote:
remote:        > [email protected] install /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-iconfont/node_modules/gulp-ttf2woff2/node_modules/ttf2woff2
remote:        > (node-gyp rebuild > builderror.log) || (exit 0)
remote:
remote:        ../csrc/addon.cc:9:20: error: ‘FunctionCallbackInfo’ does not name a type
remote:        void Convert(const FunctionCallbackInfo<Value>& args) {
remote:        ^
remote:        ../csrc/addon.cc:9:20: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
remote:        ../csrc/addon.cc:9:40: error: expected ‘,’ or ‘...’ before ‘<’ token
remote:        void Convert(const FunctionCallbackInfo<Value>& args) {
remote:        ^
remote:        ../csrc/addon.cc: In function ‘void Convert(int)’:
remote:        ../csrc/addon.cc:11:28: error: no matching function for call to ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
remote:        HandleScope scope(isolate);
remote:        ^
remote:        ../csrc/addon.cc:11:28: note: candidates are:
remote:        In file included from /app/.node-gyp/0.10.36/src/node.h:62:0,
remote:        from ../csrc/addon.cc:1:
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note: v8::HandleScope::HandleScope(const v8::HandleScope&)
remote:        HandleScope(const HandleScope&);
remote:        ^
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:473:3: note:   no known conversion for argument 1 from ‘v8::Isolate*’ to ‘const v8::HandleScope&’
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note: v8::HandleScope::HandleScope()
remote:        HandleScope();
remote:        ^
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:448:3: note:   candidate expects 0 arguments, 1 provided
remote:        ../csrc/addon.cc:13:7: error: ‘args’ was not declared in this scope
remote:        if (args.Length() < 1) {
remote:        ^
remote:        ../csrc/addon.cc:14:14: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
remote:        isolate->ThrowException(Exception::TypeError(
remote:        ^
remote:        ../csrc/addon.cc:15:9: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
remote:        String::NewFromUtf8(isolate, "Wrong number of arguments")));
remote:        ^
remote:        ../csrc/addon.cc:19:8: error: ‘args’ was not declared in this scope
remote:        if (!args[0]->IsObject()) {
remote:        ^
remote:        ../csrc/addon.cc:20:14: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
remote:        isolate->ThrowException(Exception::TypeError(
remote:        ^
remote:        ../csrc/addon.cc:21:9: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
remote:        String::NewFromUtf8(isolate, "Not an object")));
remote:        ^
remote:        ../csrc/addon.cc:25:31: error: ‘args’ was not declared in this scope
remote:        Local<Object> inputBuffer = args[0]->ToObject();
remote:        ^
remote:        ../csrc/addon.cc:28:14: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
remote:        isolate->ThrowException(Exception::TypeError(
remote:        ^
remote:        ../csrc/addon.cc:29:9: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
remote:        String::NewFromUtf8(isolate, "First arg should be a Buffer")));
remote:        ^
remote:        ../csrc/addon.cc:45:14: error: ‘class v8::Isolate’ has no member named ‘ThrowException’
remote:        isolate->ThrowException(Exception::TypeError(
remote:        ^
remote:        ../csrc/addon.cc:46:9: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
remote:        String::NewFromUtf8(isolate, "Could not convert the given font.")));
remote:        ^
remote:        ../csrc/addon.cc:49:70: error: no matching function for call to ‘node::Buffer::New(v8::Isolate*&, size_t&)’
remote:        Local<Object> slowBuffer = node::Buffer::New(isolate, output_length);
remote:        ^
remote:        ../csrc/addon.cc:49:70: note: candidates are:
remote:        In file included from ../csrc/addon.cc:2:0:
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:116:33: note: static v8::Handle<v8::Object> node::Buffer::New(v8::Handle<v8::String>)
remote:        static v8::Handle<v8::Object> New(v8::Handle<v8::String> string);
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:116:33: note:   candidate expects 1 argument, 2 provided
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:121:18: note: static node::Buffer* node::Buffer::New(size_t)
remote:        static Buffer* New(size_t length);
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:121:18: note:   candidate expects 1 argument, 2 provided
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:123:18: note: static node::Buffer* node::Buffer::New(const char*, size_t)
remote:        static Buffer* New(const char *data, size_t len);
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:123:18: note:   no known conversion for argument 1 from ‘v8::Isolate*’ to ‘const char*’
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:125:18: note: static node::Buffer* node::Buffer::New(char*, size_t, node::Buffer::free_callback, void*)
remote:        static Buffer* New(char *data, size_t length,
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:125:18: note:   candidate expects 4 arguments, 2 provided
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:129:32: note: static v8::Handle<v8::Value> node::Buffer::New(const v8::Arguments&)
remote:        static v8::Handle<v8::Value> New(const v8::Arguments &args);
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node_buffer.h:129:32: note:   candidate expects 1 argument, 2 provided
remote:        ../csrc/addon.cc:52:38: error: ‘class v8::Isolate’ has no member named ‘GetCurrentContext’
remote:        Local<Object> globalObj = isolate->GetCurrentContext()->Global();
remote:        ^
remote:        ../csrc/addon.cc:54:42: error: ‘NewFromUtf8’ is not a member of ‘v8::String’
remote:        Local<Function>::Cast(globalObj->Get(String::NewFromUtf8(isolate, "Buffer")));
remote:        ^
remote:        ../csrc/addon.cc:57:57: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, int)’
remote:        Number::New(isolate, static_cast<int>(output_length)),
remote:        ^
remote:        ../csrc/addon.cc:57:57: note: candidate is:
remote:        In file included from /app/.node-gyp/0.10.36/src/node.h:62:0,
remote:        from ../csrc/addon.cc:1:
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
remote:        V8EXPORT static Local<Number> New(double value);
remote:        ^
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
remote:        ../csrc/addon.cc:58:27: error: no matching function for call to ‘v8::Number::New(v8::Isolate*&, int)’
remote:        Number::New(isolate, 0)
remote:        ^
remote:        ../csrc/addon.cc:58:27: note: candidate is:
remote:        In file included from /app/.node-gyp/0.10.36/src/node.h:62:0,
remote:        from ../csrc/addon.cc:1:
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note: static v8::Local<v8::Number> v8::Number::New(double)
remote:        V8EXPORT static Local<Number> New(double value);
remote:        ^
remote:        /app/.node-gyp/0.10.36/deps/v8/include/v8.h:1381:33: note:   candidate expects 1 argument, 2 provided
remote:        ../csrc/addon.cc: In function ‘void Init(v8::Handle<v8::Object>)’:
remote:        ../csrc/addon.cc:65:46: error: no matching function for call to ‘SetMethod(v8::Handle<v8::Object>&, const char [8], void (&)(int))’
remote:        NODE_SET_METHOD(exports, "convert", Convert);
remote:        ^
remote:        ../csrc/addon.cc:65:46: note: candidate is:
remote:        In file included from ../csrc/addon.cc:1:0:
remote:        /app/.node-gyp/0.10.36/src/node.h:112:6: note: template<class target_t> void node::SetMethod(target_t, const char*, v8::InvocationCallback)
remote:        void SetMethod(target_t obj, const char* name,
remote:        ^
remote:        /app/.node-gyp/0.10.36/src/node.h:112:6: note:   template argument deduction/substitution failed:
remote:        ../csrc/addon.cc:65:46: note:   cannot convert ‘Convert’ (type ‘void(int)’) to type ‘v8::InvocationCallback {aka v8::Handle<v8::Value> (*)(const v8::Arguments&)}’
remote:        NODE_SET_METHOD(exports, "convert", Convert);
remote:        ^
remote:        make: *** [Release/obj.target/addon/csrc/addon.o] Error 1
remote:        gyp ERR! build error
remote:        gyp ERR! stack Error: `make` failed with exit code: 2
remote:        gyp ERR! stack     at ChildProcess.onExit (/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
remote:        gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
remote:        gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
remote:        gyp ERR! System Linux 3.13.0-66-generic
remote:        gyp ERR! command "node" "/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote:        gyp ERR! cwd /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-iconfont/node_modules/gulp-ttf2woff2/node_modules/ttf2woff2
remote:        gyp ERR! node -v v0.10.36
remote:        gyp ERR! node-gyp -v v1.0.2
remote:        gyp ERR! not ok
remote:
remote:        > gulp-rails@ postinstall /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf
remote:        > gulp build
remote:
remote:
remote:        /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/node_modules/gulp-iconfont/node_modules/gulp-ttf2woff2/node_modules/ttf2woff2/jssrc/ttf2woff2.js:1
remote:        aughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Mod
remote:        ^
remote:        Error: Cannot find module 'gulp-watch'
remote:        at Function.Module._resolveFilename (module.js:338:15)
remote:        at Function.Module._load (module.js:280:25)
remote:        at Module.require (module.js:364:17)
remote:        at require (module.js:380:17)
remote:        at Object.<anonymous> (/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/gulp/tasks/watch.js:8:14)
remote:        at Module._compile (module.js:456:26)
remote:        at Object.Module._extensions..js (module.js:474:10)
remote:        at Module.load (module.js:356:32)
remote:        at Function.Module._load (module.js:312:12)
remote:        at Module.require (module.js:364:17)
remote:
remote:        npm ERR! Linux 3.13.0-66-generic
remote:        npm ERR! argv "node" "/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/.npmrc"
remote:        npm ERR! node v0.10.36
remote:        npm ERR! npm  v2.3.0
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! gulp-rails@ postinstall: `gulp build`
remote:        npm ERR! Exit status 7
remote:        npm ERR!
remote:        npm ERR! Failed at the gulp-rails@ postinstall script 'gulp build'.
remote:        npm ERR! This is most likely a problem with the gulp-rails package,
remote:        npm ERR! not with npm itself.
remote:        npm ERR! Tell the author that this fails on your system:
remote:        npm ERR!     gulp build
remote:        npm ERR! You can get their info via:
remote:        npm ERR!     npm owner ls gulp-rails
remote:        npm ERR! There is likely additional logging output above.
remote:
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_fee504646fcf321c4eaf1bbb5a745bbf/npm-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:
remote:  !     Push rejected, failed to compile Multipack app
remote:
remote: Verifying deploy...
remote:
remote: !   Push rejected to seedfeed-production.
remote:
To [email protected]:seedfeed-production.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:seedfeed-production.git'

No sass or coffee watch

I've managed to setup gulp pipeline on vagrant. It wasn't easy, but it almost works. The only thing that is not working is watching scss or coffee script. When i change any view in app/views live reload occurs without a problem. But when i change global.sass nothing happens. It even don't get browsified. Just like file watch wasn't working.

Any idea what can be couse of that? I'm pretty new to gulp so i could use an advice how to debug task.

Sass change does not call browserSync but browserify change does

Not sure why but for me, saving the global.sass does not cause browserSync to reload/inject styles. Although gulp does detect the change in the file and recompiles the css it does not reload the tab. Changes to global.coffee however, do both compile the js and reload the tab ....

Drop-in solution

I'm wondering if it's realistic to have a branch/repo of this project which contains just the files needed to make it work - or maybe a rails generator or something?

I've got an existing app which I want to use this on, but currently have to go though and manually make all of the changes - so was wondering if there was an easier way to do so.

Thanks :)

Grunt version

Hey

Is there a Grunt version of this as it would be exactly what I'm looking for.

Not compatible with Puma

We've noticed a strange issue when using the Puma webserver instead of Webrick. Browser-sync will try to run on port 3000 (the same port the rails app is already being served on). I've noticed on your sample app that browser-sync runs on 3001. Gulp recognizes changes to files but the app does not live reload. It also causes serious memory and cpu drain on the computer.

Maybe there is a configuration change we need to make to Puma?

Heroku - Couldn't find the file 'global'

Tried to deploy a clone of the repo but unfortunately it seems that, at least for the first time you can't require any assets from gems.

Because heroku has a "buildpack-detect-order" it runs ruby before the nodejs stuff.
https://devcenter.heroku.com/articles/buildpacks#default-buildpacks

What happens is the following

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Sprockets::FileNotFound: couldn't find file 'global'
       (in /tmp/build_555261d13cd0900aa0a0d6e8b80d45dc/app/assets/javascripts/application.js:12)

npm install fails

I cannot get 'npm install' to succeed in this project. I keep getting the following error:

> gulp-rails@ postinstall /Users/peter/projects/lifesizey/gulp-rails-pipeline
> gulp build

util.js:634
  ctor.prototype = Object.create(superCtor.prototype, {
                                          ^
TypeError: Cannot read property 'prototype' of undefined
    at Object.exports.inherits (util.js:634:43)
    at Object.<anonymous> (/Users/peter/projects/lifesizey/gulp-rails-pipeline/node_modules/browser-sync/node_modules/http-proxy/lib/http-proxy/index.js:108:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/peter/projects/lifesizey/gulp-rails-pipeline/node_modules/browser-sync/node_modules/http-proxy/lib/http-proxy.js:4:17)
    at Module._compile (module.js:460:26)

npm ERR! Darwin 14.3.0
npm ERR! argv "/Users/peter/.nvm/v0.12.2/bin/node" "/Users/peter/.nvm/v0.12.2/bin/npm" "install"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! gulp-rails@ postinstall: `gulp build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gulp-rails@ postinstall script 'gulp build'.
npm ERR! This is most likely a problem with the gulp-rails package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp build

I have tried with various versions of node 0.10, 0.11 and 0.12 but always get the same error. Any suggestions on how to resolve this? Googling around got me nowhere... thanks

Rails asset caching

Hi, first thank you for the sample setup.
I've followed the steps described to run the sample setup locally as well as for deployment.
Building the assets into /public/assets on heroku deploy works up until noticing that the gulp rev is having no effect on what Rails serves as assets. When inspecting the response of the digested application-xxx.css file, the asset paths have not been updated to match rev-manifest.json.

config.serve_static_files is true for production, as well as the other setup instructions have been followed for deployment.

I'm suspecting Rails asset caching is interfering during production. This is also my guess since looking into the dyno tree shows old assets:
$ heroku run bash ...
~/public/assets/fonts $ ls -l
total 44
-rw------- 1 u58246 58246 1140 Mar 2 19:57 gulp-rails-icons-02b88d2d.woff
-rw------- 1 u58246 58246 1856 Mar 2 19:57 gulp-rails-icons-0e6afbba.ttf
-rw------- 1 u58246 58246 1140 Mar 2 19:49 gulp-rails-icons-463bf8ff.woff
-rw------- 1 u58246 58246 1856 Mar 2 19:49 gulp-rails-icons-74cc4a04.ttf
-rw------- 1 u58246 58246 3180 Mar 2 19:49 gulp-rails-icons-9249053b.svg
-rw------- 1 u58246 58246 2056 Mar 2 19:49 gulp-rails-icons-d62f0c22.eot
-rw------- 1 u58246 58246 2056 Mar 2 19:57 gulp-rails-icons-ef16004a.eot
-rw------- 1 u58246 58246 2056 Mar 2 19:37 gulp-rails-icons.eot
-rw------- 1 u58246 58246 3180 Mar 2 19:37 gulp-rails-icons.svg
-rw------- 1 u58246 58246 1856 Mar 2 19:37 gulp-rails-icons.ttf
-rw------- 1 u58246 58246 1140 Mar 2 19:37 gulp-rails-icons.woff

Can I get some help in configuring the deploy process so during remote production build I can match exactly what gets spit out as assets by Rails in this repo? :
https://gulp-rails-pipeline.herokuapp.com/

Fails to build on heroku

Error: Cannot find module 'gulp-watch'
remote: at Function.Module._resolveFilename (module.js:338:15)
remote: at Function.Module._load (module.js:280:25)
remote: at Module.require (module.js:364:17)
remote: at require (module.js:380:17)
remote: at Object. (/tmp/build_310d1461a5bfcb66a7cd499838db21ac/gulp/tasks/watch.js:8:14)
remote: at Module._compile (module.js:456:26)
remote: at Object.Module._extensions..js (module.js:474:10)
remote: at Module.load (module.js:356:32)
remote: at Function.Module._load (module.js:312:12)
remote: at Module.require (module.js:364:17)

It appears gulp-watch is required on in tasks/watch.js which is apparently being somehow run when heroku runs gulp build. I'm not sure how exactly as I am a gulp/nodejs newbie. But of course, gulp-watch is only a dev dependency and so not on heroku.

Can't redeploy to Heroku

So after a lot of work, I finally got this deployed to Heroku.

However, now when I try to re-deploy after making some changes, I get the following error:

± git push production master
Counting objects: 29, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (19/19), 1.61 KiB | 0 bytes/s, done.
Total 19 (delta 15), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/ddollar/heroku-buildpack-multi.git... done
remote: -----> Multipack app detected
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
remote: =====> Detected Framework: Node.js
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  0.12.7
remote:        engines.npm (package.json):   2.14.4
remote:
remote:        Downloading and installing node 0.12.7...
remote:        Downloading and installing npm 2.14.4 (replacing version 2.11.3)...
remote:
remote: -----> Restoring cache
remote:        Loading 2 from cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote:        Pruning any extraneous modules
remote:        Installing node modules (package.json)
remote:
remote:        > gulp-rails@ postinstall /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c
remote:        > gulp build
remote:
remote:        [06:10:31] Using gulpfile /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/gulpfile.js
remote:        [06:10:31] Starting 'build'...
remote:        [06:10:31] Starting 'clean'...
remote:        [06:10:31] Finished 'clean' after 6.91 ms
remote:        [06:10:31] Starting 'iconFont'...
remote:        [06:10:31] Starting 'images'...
remote:        [06:10:31] gulp-svgicons2svgfont: Font created
remote:        [06:10:32] Finished 'iconFont' after 432 ms
remote:        [06:10:32] gulp-imagemin: Minified 9 images (saved 25.43 kB - 8.9%)
remote:        [06:10:32] Finished 'images' after 1.01 s
remote:        [06:10:32] Starting 'sass'...
remote:        [06:10:32] Starting 'browserify'...
remote:        [06:10:32] Bundling global.js...
remote:        [06:10:32] Finished 'sass' after 285 ms
remote:        [06:10:36] Bundled global.js in 3.81 s
remote:        [06:10:36] Finished 'browserify' after 3.83 s
remote:        [06:10:36] Starting 'rev-assets'...
remote:        [06:10:36] Finished 'rev-assets' after 40 ms
remote:        [06:10:36] Starting 'rev-font-workaround'...
remote:        [06:10:36] 'rev-font-workaround' errored after 640 μs
remote:        [06:10:36] TypeError: Cannot read property 'split' of undefined
remote:        at /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/gulp/tasks/rev/rev-font-workaround.js:30:42
remote:        at forOwn (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/lodash/dist/lodash.js:2106:15)
remote:        at Function.forEach (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/lodash/dist/lodash.js:3303:9)
remote:        at Gulp.<anonymous> (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/gulp/tasks/rev/rev-font-workaround.js:25:5)
remote:        at module.exports (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
remote:        at Gulp.Orchestrator._runTask (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
remote:        at Gulp.Orchestrator._runStep (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
remote:        at /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/index.js:279:18
remote:        at finish (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
remote:        at /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:52:4
remote:        at f (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/node_modules/end-of-stream/node_modules/once/once.js:17:25)
remote:        at DestroyableTransform.onend (/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/orchestrator/node_modules/end-of-stream/index.js:31:18)
remote:        at DestroyableTransform.emit (events.js:129:20)
remote:        at /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
remote:        at process._tickCallback (node.js:355:11)
remote:
remote:
remote:        npm ERR! Linux 3.13.0-66-generic
remote:        npm ERR! argv "node" "/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/.npmrc"
remote:        npm ERR! node v0.12.7
remote:        npm ERR! npm  v2.14.4
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! gulp-rails@ postinstall: `gulp build`
remote:        npm ERR! Exit status 1
remote:        npm ERR!
remote:        npm ERR! Failed at the gulp-rails@ postinstall script 'gulp build'.
remote:        npm ERR! This is most likely a problem with the gulp-rails package,
remote:        npm ERR! not with npm itself.
remote:        npm ERR! Tell the author that this fails on your system:
remote:        npm ERR!     gulp build
remote:        npm ERR! You can get their info via:
remote:        npm ERR!     npm owner ls gulp-rails
remote:        npm ERR! There is likely additional logging output above.
remote:
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_a04984ffdd9d47cbfa3be2e3dd43541c/npm-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:
remote:  !     Push rejected, failed to compile Multipack app
remote:
remote: Verifying deploy...
remote:
remote: !   Push rejected to seedfeed-production.
remote:
To [email protected]:seedfeed-production.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:seedfeed-production.git'

Anyone know what's going on?

RAILS_ENV=production rake assets:precompile fails locally

Thanks for open sourcing this project.

I spent some time debugging this issue. The culprit appears to be the removal of image-url in node-sass/libsass lately:

sass/node-sass#965

The output of gulp build creates a global.css with image-url still in it:

body {
 58   background: #dd3435 image-url("gulp.png");
 59   font-family: sans-serif; }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.