Git Product home page Git Product logo

rake-pipeline-web-filters's Introduction

Rake::Pipeline::Web::Filters Build Status

This project contains a set of rake-pipeline filters for building web apps.

It includes these filters:

  • Cache Buster - Write a fingerprint into each file name
  • Coffescript - Convert Coffeescript to Javascript
  • ES6 Module Transpiler - Transpile ES6 to ES5 Javascript (Available Options)
  • GZip - Create gzip'd version of your files
  • Handlebars - Process handlebars templates
  • IIFE - Wrap source files in Immediately Invoked Function Expressions
  • Jade - Process Jade templates
  • LESS - Convert LESS to CSS
  • Markdown - Convert Markdown to HTML
  • Minispade - Wrap JS files in Minispade modules
  • Neuter - Require files in a file and generate one single combined file
  • SASS - Convert SASS to CSS
  • Stylus - Convert Stylus to CSS
  • Tilt - Use Tilt to process
  • Uglify - Minify JS
  • YUI CSS - Minify CSS
  • YUI Javascript - Minify JS

Here's a quick example of a realistic project's Assetfile:

# Assetfile
require 'rake-pipeline-web-filters'

output "site"

input "javascripts" do
  match "**/*.coffee" do
    coffee_script
  end

  match "**/*.js" do
    minispade
    concat "application.js"
    uglify
  end
end

input "stylesheets" do
  match "**/*.sass" do
    sass
  end

  match "**/*.css" do
    concat "application.css"
    yui_css
  end
end

API documentation is hosted at rubydoc.info

rake-pipeline-web-filters's People

Contributors

balinterdi avatar dudleyf avatar ghempton avatar hjr3 avatar indirect avatar izhan avatar kelonye avatar krisselden avatar lukemelia avatar morgoth avatar pootsbook avatar qoobaa avatar raghurajah avatar renz45 avatar systho avatar tdreyno avatar tomdale avatar wagenet avatar wycats 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

rake-pipeline-web-filters's Issues

NeuterFilter does not support coffeescript

lib/main.js

require("a.js")

lib/a.coffee

console.log("a.coffee")

Assetfile

input "lib" do
  match "*.coffee" do
    coffee_script
  end

  match "main.js" do
    neuter "app.js"
  end
end
$ bundle exec rakep
> can't find lib/a.js

Add "use strict" as an option for minispade filter

It's a good general practice to add "use strict"; to the top of each major function. It would be nice to have a strict option on the filter that would add it just inside the function() { } wrapper.

Why not just have the user put it in each source file? Because global "use strict"; is a bad idea, so things like JSHint expect it to be inside a function() {}() call. To do this in the source files means that each source file would have to look like

(function() {
  "use strict";
  ...
}());

which would then get compiled to

minispade.register('filename', function() {
  (function() {
    "use strict";
    ...
  }());
});

There's nothing wrong with that, but it seems wasteful.

UglifyJS bug fix not included

mishoo/UglifyJS#126

So this is probably more of a Ruby gem issue than here, but uglifyjs is stripping the last semicolon of the file, which generates a very hard to find bug when concatenating file together. Looks like it was fixed but the latest ruby gem hasn't pulled it in. Perhaps we can work around it until then?

SassFilter doesn't rebuild imported files

Typical usage of the SassFilter is to match a single file and use Sass's @imports to load additional sass files. Unfortunately, when we do this, rakep knows nothing of the imported files and won't rebuild when one changes.

Autoprefixer support

Autoprefixer is a best tool to works with vendor prefixes in CSS. It parse CSS and add vendor prefixes to CSS rules using values from the Can I Use.

Paul Irish and Chris Coyier recommend it. CodePen, Feedbin use it. Bootstrap and Wordpress will use it soon.

SassFilter dies if its input files don't exist at setup time

The SassFilter will only work if its input files exist when the pipeline gets setup. If the SassFilter is the first filter in the pipeline, then the input root is the original source file, so it exists, so it can be read to extract its dependencies. If another filter matches the same input before the SassFilter, however, then the file's input root will be a temporary directory, and the file won't be there until the pipeline is actually invoked. The SassFilter needs to read the file at setup time, not at invoke time.

For example:

input "app/assets" do
  match("stylesheets/app.scss") do
    sass
  end
end

works. The SassFilter reads app/assets/stylesheets/app.scss when the pipeline is setup. This:

input "app/assets" do
  match("stylesheets/app.scss") do
    copy
    sass
  end
end

dies horribly because the SassFilter is trying to read my-tmp-dir/rake-pipeline-tmp-1/stylesheets/app.scss, which isn't created until the pipeline is invoked.

Rake Pipeline OrderingConcatFilter by folder

How can I specify an entire folder when specifying OrderingConcatFilter?

      match "coffee/**/*.js" do
        filter(
          Rake::Pipeline::OrderingConcatFilter,
          [
            "my/essentials/**/*",
            "my/core/**/*",
          ],
          "libs.js"
        )
      end

I wrote my app in a javascript MVC and the way it works is all the files in that directory need to be loaded before the rest, how can I specify wild characters?

compass is required even if not using SassCompiler

lib/rake-pipeline-web-filters.rb does a require "rake-pipeline-web-filters/sass_compiler" and that in turn does a require "compass". Thus, simply requiring the library requires Compass, even if the user isn't using the SassCompiler at all. Some options:

  1. force the user to require each filter individually
  2. use autoload
  3. move the require "compass" into the intitializer and raise a meaningful error if it's unavailable

(1) is frustrating. (2) feels icky. How would (3) work in multi-threaded environments?

configuring sass filter

Passing options to the filter doesn't seem to be working but I'm sure I've missed something. Are there any examples floating around? Perhaps of one configuring the asset host?

Error with CacheBusterFilter at End of Pipeline

Perhaps I'm doing this wrong, but I get an error with the following Assetfile:

output "public"
input "assets", "**/*.js" do
  concat "application.js"
  filter Rake::Pipeline::Web::Filters::CacheBusterFilter
end

I get an Errno::ENOENT:

No such file or directory - /.path/to/rake-pipeline-tmp-1/application.js (Errno::ENOENT)

This might be similar to issue #19 whereby the filter only works if the input files exist when the pipeline gets set up, though I can't be sure.

CoffeeScript causing odd problems

Here is my asset file

match "**/*.handlebars" do
  handlebars
end

match "**/*.coffee" do
  coffee_script
end

match "{javascripts,vendor/javascripts}/**/*.js" do
  minispade :module_id_generator => proc { |input|
    if input.path =~ /vendor/
      File.basename input.path, '.js'
    else
      input.path.gsub(/javascripts\//, "todos/").gsub(/\.js$/, '')
    end
  }

  concat "application.js"
end

match "**/*.{css,scss}" do
  sass

  concat "application.css"
end

match "public/**/*" do
  copy do |input|
    input.sub(/public\//, '')
  end
end

match "images/**/*" do
  copy
end

I have files like 'app/vendor/javascripts/backbone.js'. I'd like those turned to minispade modules named 'backbone'. This works sometimes.
I've been trying to track down the problem. The minispade modules are being written as: vendor/todos/jquery.

Seen here:

adam at mba : ~/projects/frontend_server_example[master*] % grep jquery public/application.js        
});minispade.register('todos/boot', function() {minispade.require('jquery');
});minispade.register('vendor/todos/jquery', function() {/*!

Now after much debugging, I found the problem. I commented out the coffeescript section (I have no cofeescript files) and voila! Much to my surprise, the generated javascript is different:

adam at mba : ~/projects/frontend_server_example[master*] % grep jquery public/application.js        
});minispade.register('todos/boot', function() {minispade.require('jquery');
});minispade.register('jquery', function() {/*!

^ That's what I expect should happen, but it doesn't happen when coffescript is there.

I really have no clue what is happening with this. It's a very odd bug from my point of view. So apparently the file names are changing even though the CS filter isn't being used?

Release a new gem version

The most recent version on rubygems is 0.5.0 from December 2011. There are a number of valuable new filters available now.

Add webp Filter

Would it be ok if I added a webp filter? It would add native dependencies.

Remove OrderingConcatFilter

Rake::Pipeline::Web::Filters::OrderingConcatFilter has moved to rake-pipeline. Do we need to worry about deprecations at this point, or can we just drop the old one?

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.