Giter Club home page Giter Club logo

ngmin-rails's Introduction

ngmin-rails's People

Contributors

jasonm avatar michaelglass 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

Watchers

 avatar  avatar  avatar  avatar

ngmin-rails's Issues

"Self is not defined" Error Whenever `rake assets:precompile` is run

Ruby 2.0, Rails 4.0
The following error appears whenever I run rake assets:precompile

rake aborted!
self is not defined
  (in /home/samz/dev/vidcom/app/assets/javascripts/application.js.coffee)
at ./package.json (<eval>:5090:12)
at s (<eval>:1:233)
at <eval>:1:284
at astral (<eval>:4099:15)
at s (<eval>:1:233)
at e (<eval>:1:404)
at <eval>:1:422

Please help me resolve this problem. Thanks!

EDIT:
There's no undefined "self" anywhere in my application.js.coffee except for the require_self line, and the problem persists even if I remove require_self

#= require jquery
#= require jquery_ujs
#= require twitter/bootstrap
#= require unstable/angular
#= require unstable/angular-resource
#= require underscore
#= require_self
#= require_tree ./vendor
#= require_tree ./configs
#= require_tree ./models
#= require_tree ./directives
#= require_tree ./filters
#= require_tree ./controllers
#= require_tree ./misc

window.app = angular.module "myApp", ["restangular"]

Prevent ngmin to run in when developing

HI, I added the gem in my Gemfile in the assets group

group :assets do
    gem 'ngmin-rails'
end

But when I'm developing I get the js file minimized. There is any way to prevent that?

CoffeeScript Rails4 - Not Doing Anything

Am I on track that this:

UserSettingsCtrl = ($scope, $cookieStore, $location, SessionService, AlertService, CurrentUser) ->

  $scope.saveUserSettings = ->
    $scope.newSupport.proposal_id = $scope.clicked_proposal.id
    AlertService.clearAlerts()

   ....

# Register
App.controller 'UserSettingsCtrl', UserSettingsCtrl

Should compile correctly with the added in line notation?:

[ '$scope', '$cookieStore', '$location', 'SessionService', 'AlertService', 'CurrentUser' ]

All the examples seem to show the

angular.module('myModuleName').
  service('myFirstService', .....

notation. Of course I'm doing that later in my master app file

window.App = angular.module('spokenvote', [ 'ngRoute', 'spokenvote.services', 'spokenvote.directives', 'ui', 'ui.bootstrap' ]).config(appConfig)

I'm just adding the gem

group :production, :staging do
  gem 'rails_12factor'
  gem 'newrelic_rpm', '3.5.5.38'
  gem "airbrake"
  gem 'prerender_rails'
  gem 'fog'
  gem 'ngmin-rails', '~> 0.4.0'
end

Then ...

  • Clobbering all my public/assets,
  • Deleting my temp/cache/assets
  • Bundle install
  • Pre compile assets as Staging
  • Restarting the server as Staging

... but the added DI inline notation does not seem to show up and load fails over DI error.

See anything wrong with my expectations or methods?

Not worked in Heroku

Worked on my local production env. But not worked in heroku. Heroku seems use a different asset command.
I'll check more later

assets:precompile fails with ngmin-rails 0.4.0 and ActiveAdmin 0.6.0

We have been migrating a site to a new cluster of servers that are using nodejs as the JS runtime (as therubyracer was causing issues). During asset precompilation, it seems that ngmin-rails is trying to parse one of the ActiveAdmin CoffeScript files as JavaScript instead.

Here is the output of rake assets:precompile:

+ bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby ../ruby/2.0.0/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets
===================================================
/tmp/execjs20130925-12469-1sorgh4.js
===================================================
===================================================
/tmp/execjs20130925-12469-g3omuc.js
===================================================
===================================================
/tmp/execjs20130925-12469-1v9h48p.js
===================================================
===================================================
/tmp/execjs20130925-12469-1s2v70y.js
===================================================
===================================================
/tmp/execjs20130925-12469-hjws4g.js
===================================================
===================================================
/tmp/execjs20130925-12469-17w9xqu.js
===================================================
===================================================
/tmp/execjs20130925-12469-1ypbu0a.js
===================================================
===================================================
/tmp/execjs20130925-12469-1mc71z6.js
===================================================
===================================================
/tmp/execjs20130925-12469-8guyd9.js
===================================================
===================================================
/tmp/execjs20130925-12469-1rvkzra.js
===================================================
rake aborted!
Error: Line 1: Unexpected token ILLEGAL
  (in ../ruby/2.0.0/gems/activeadmin-0.6.0/app/assets/javascripts/active_admin/lib/namespace.js.coffee)
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:73:in `extract_result'
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:33:in `block in exec'
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:46:in `compile_to_tempfile'
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:27:in `exec'
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:19:in `eval'
../ruby/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:38:in `call'
../ruby/2.0.0/gems/ngmin-rails-0.4.0/lib/ngmin/processor.rb:15:in `evaluate'
../ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/unprocessed_asset.rb:14:in `initialize'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `new'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:91:in `block in build_required_assets'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:85:in `each'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:85:in `build_required_assets'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/unprocessed_asset.rb:27:in `initialize'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `new'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:91:in `block in build_required_assets'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:85:in `each'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/asset_with_dependencies.rb:85:in `build_required_assets'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/sprockets/unprocessed_asset.rb:27:in `initialize'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `new'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/bundled_asset.rb:12:in `initialize'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:22:in `new'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/base.rb:22:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/static_compiler.rb:32:in `block in compile'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
../ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/sprockets_overrides/static_compiler.rb:29:in `compile'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/tasks/assets.rake:108:in `internal_precompile'
../ruby/2.0.0/gems/turbo-sprockets-rails3-0.3.10/lib/turbo-sprockets/tasks/assets.rake:115:in `block (3 levels) in <top (required)>'
Tasks: TOP => assets:precompile:all

Here is the contents of the file in question (namespace.js.coffee):

# Make a namespace for ActiveAdmin plugins  

window.AA = {}

As you can see, the first line is a valid comment for CoffeeScript only, and parsing it as JavaScript will throw an illegal token error.

The gems that we are using:

Using rake (10.1.0) 
Using i18n (0.6.1) 
Using multi_json (1.7.8) 
Using activesupport (3.2.13) 
Using builder (3.0.4) 
Using activemodel (3.2.13) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.3) 
Using tilt (1.4.1) 
Using sprockets (2.2.2) 
Using actionpack (3.2.13) 
Using mime-types (1.23) 
Using polyglot (0.3.3) 
Using treetop (1.4.14) 
Using mail (2.5.4) 
Using actionmailer (3.2.13) 
Using arbre (1.0.1) 
Using sass (3.2.9) 
Using thor (0.18.1) 
Using bourbon (3.1.8) 
Using bcrypt-ruby (3.1.1) 
Using orm_adapter (0.4.0) 
Using rack-ssl (1.3.3) 
Using json (1.8.0) 
Using rdoc (3.12.2) 
Using railties (3.2.13) 
Using warden (1.2.3) 
Using devise (3.0.0) 
Using fastercsv (1.5.5) 
Using formtastic (2.2.1) 
Using has_scope (0.5.1) 
Using responders (0.9.3) 
Using inherited_resources (1.4.0) 
Using jquery-rails (3.0.2) 
Using kaminari (0.14.1) 
Using arel (3.0.2) 
Using tzinfo (0.3.37) 
Using activerecord (3.2.13) 
Using polyamorous (0.5.0) 
Using meta_search (1.1.3) 
Using activeresource (3.2.13) 
Using bundler (1.3.5) 
Using rails (3.2.13) 
Using activeadmin (0.6.0) 
Using pg (0.15.1) 
Using activerecord-postgresql-adapter (0.0.1) 
Using acts_as_paranoid (0.4.2) 
Using addressable (2.3.5) 
Using angularjs-rails (1.0.6) 
Using mini_portile (0.5.1) 
Using nokogiri (1.6.0) 
Using uuidtools (2.1.4) 
Using aws-sdk (1.11.1) 
Using coderay (1.0.9) 
Using better_errors (0.9.0) 
Using debug_inspector (0.0.2) 
Using binding_of_caller (0.7.2) 
Using bootstrap-sass (2.3.2.1) 
Using uniform_notifier (1.2.0) 
Using bullet (4.6.0) 
Using callsite (0.0.11) 
Using cancan (1.6.10) 
Using highline (1.6.19) 
Using net-ssh (2.6.8) 
Using net-scp (1.1.2) 
Using net-sftp (2.1.2) 
Using net-ssh-gateway (1.2.0) 
Using capistrano (2.15.5) 
Using capistrano-ext (1.2.1) 
Using xpath (2.0.0) 
Using capybara (2.1.0) 
Using carrierwave (0.9.0) 
Using carrierwave_backgrounder (0.2.1) 
Using ffi (1.9.0) 
Using childprocess (0.3.9) 
Using choice (0.1.6) 
Using coffee-script-source (1.6.3) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using coffee-rails (3.2.2) 
Using columnize (0.3.6) 
Using country-select (1.1.1) 
Using daemons (1.1.9) 
Using database_cleaner (1.0.1) 
Using debugger-linecache (1.2.0) 
Using debugger-ruby_core_source (1.2.3) 
Using debugger (1.6.0) 
Using delayed_job (3.0.5) 
Using delayed_job_active_record (0.4.4) 
Using diff-lcs (1.2.4) 
Using eventmachine (1.0.3) 
Using exception_notification (4.0.0) 
Using excon (0.20.1) 
Using factory_girl (4.2.0) 
Using factory_girl_rails (4.2.1) 
Using faker (1.1.2) 
Using formatador (0.2.4) 
Using ruby-hmac (0.4.0) 
Using fog (0.7.2) 
Using rb-fsevent (0.9.3) 
Using rb-inotify (0.9.0) 
Using rb-kqueue (0.2.0) 
Using listen (1.2.2) 
Using lumberjack (1.0.4) 
Using method_source (0.8.1) 
Using slop (3.4.5) 
Using pry (0.9.12.2) 
Using guard (1.8.1) 
Using guard-jasmine (1.18.1) 
Using rspec-core (2.14.0) 
Using rspec-expectations (2.14.0) 
Using rspec-mocks (2.14.1) 
Using rspec (2.14.0) 
Using guard-rspec (3.0.2) 
Using haml (4.0.3) 
Using jasminerice (0.0.10) 
Using jquery-fileupload-rails (0.4.1) 
Using jquery-ui-rails (4.0.3) 
Using kaminari-bootstrap (0.1.3) 
Using launchy (2.3.0) 
Using letter_opener (1.1.2) 
Using rack-contrib (1.1.0) 
Using meta_request (0.2.7) 
Using ngmin-rails (0.4.0) 
Using quiet_assets (1.0.2) 
Using ruby-graphviz (1.0.9) 
Using rails-erd (1.1.0) 
Using rails_config (0.3.3) 
Using rest-client (1.6.7) 
Using rmagick (2.13.2) 
Using rspec-rails (2.14.0) 
Using rubyzip (0.9.9) 
Using rufus-scheduler (2.0.24) 
Using rvm-capistrano (1.3.4) 
Using sass-rails (3.2.6) 
Using s3_direct_upload (0.1.6) 
Using websocket (1.0.7) 
Using selenium-webdriver (2.33.0) 
Using shoulda-context (1.1.4) 
Using shoulda-matchers (2.2.0) 
Using shoulda (3.5.0) 
Using simplecov-html (0.7.1) 
Using simplecov (0.7.1) 
Using spinjs-rails (1.3) 
Using strong_parameters (0.2.1) 
Using thin (1.5.1) 
Using turbo-sprockets-rails3 (0.3.10) 
Using uglifier (2.1.1) 
Using yell (1.4.0) 
Using yell-adapters-gelf (1.2.0) from git://github.com/rudionrails/yell-adapters-gelf.git (at master) 
Using yell-rails (1.4.0) 

rake assets:precompile succeeds if we remove ngmin-rails from the Gemfile.

Rails 4 compatibility

Has this gem been proven to work on Rails 4? I've followed the two instructions but it doesn't seem to do anything. Assets get packaged with same angular provider borks.

From gemfile:

  gem 'ngmin-rails'
  gem 'sass-rails',   '~> 4.0.0.beta1'
  gem 'coffee-rails', '~> 4.0.0.beta1'

  gem 'uglifier', '>= 1.0.3'

Issue with source maps

In order to work with javascript source maps you add comment that looks like
//# sourceMappingURL=/assets/source_maps/app/assets/javascripts/app.map
in the end of your file.
.js files resulting from .coffee were missing this comment.
After some debugging I found that it was this preprocessor that was deleting it.

In order to solve this problem I moved this gem to "production" group, because I don't use source maps there.

I know that this is mostly ngmin parsing problem which won't be solved here, but I simply want to save other people headache by mentioning this problem.

Since this doesn't require any solution from ngmin-rails part it should be closed, I simply want it to remain here as a piece of warning/documentation.

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.