Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Ngmin::Processor into bundle processor, so make module defined in seperate file works #8

Closed
wants to merge 1 commit into from

Conversation

raykin
Copy link

@raykin raykin commented Sep 25, 2013

No description provided.

@raykin raykin mentioned this pull request Sep 25, 2013
@raykin
Copy link
Author

raykin commented Sep 27, 2013

After searching the source, sprockets considered js and css as bundled assets and always run bundle prorcessor when run rake assets:precompile.

# sprockets/mainfest.rb
    def compile(*args)
      unless environment
        raise Error, "manifest requires environment for compilation"
      end

      paths = environment.each_logical_path(*args).to_a +
        args.flatten.select { |fn| Pathname.new(fn).absolute? if fn.is_a?(String)}

      paths.each do |path|
        if asset = find_asset(path)

the last line will create a bundled asset for javascript asset.
So only the user override the compile and write something like

   if asset = find_asset(path, bundle: false)

Then the bundle processor will be ignore.

Actually that's how development env did. In development, we query
http://localhost:3000/assets/ctrl/doc.js?body=1 to get each js file if the rails config config.assets.debug = true.
then sprockets will render this js asset as ProcessedAsset, no any processors run.

# sprockets/server
      def call(env)
      ... 
       # Look up the asset.
      asset = find_asset(path, :bundle => !body_only?(env))
      ...
      end

      # Test if `?body=1` or `body=true` query param is set
      def body_only?(env)
        env["QUERY_STRING"].to_s =~ /body=(1|t)/
      end

Since we only care about the rake assets:precompile, I think it's safe to remove the postprocessor

@jasonm
Copy link
Owner

jasonm commented May 17, 2014

Hi @raykin - sorry for the delayed response. I haven't used this (or Angular) in a long time, so I'm deprecating the project in favor of ngannotate-rails, which makes use of ng-annotate which possibly supercedes ngmin.

@jasonm jasonm closed this May 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants