Git Product home page Git Product logo

sprockets-standalone's Introduction

Sprockets::Standalone

Rack task library for using Sprockets standalone.

Installation

Add this line to your application's Gemfile:

gem 'sprockets-standalone'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sprockets-standalone

Usage

Require sprockets-standalone in your Rakefile and define the task:

require 'sprockets/standalone'

Sprockets::Standalone::RakeTask.new(:assets) do |task, sprockets|
  task.assets   = %w(app.js app.css *.png *.svg *.woff)
  task.sources  = %w(app/assets vendor/assets)
  task.output   = File.expand_path('../assets', __FILE__)
  task.compress = false
  task.digest   = false

  sprockets.js_compressor  = :uglifier
  sprockets.css_compressor = :sass
end

You can give a name to the task that will be used for namespacing. The example above will generate the rake tasksassets:compile, assets:clobber and assets:clean. Default value for name is assets.

If you pass a block you can configure additional parameters:

  1. task.assets - Defines the list of assets that should be compiled for you. By default it contains application.js, application.css and *.png, *.jpg, *.gif.

  2. task.source - Defines a list of source directories. The specified paths will be added to sprockets' include path. If you want a sprockets directory structure similar to Rails you need to add all paths: task.sources = %w(app/assets/javascripts app/assets/stylesheets app/assets/images).

  3. task.output - Define output directory. Default is dist.

  4. task.compress - Set to true if you want pre-compressed assets. Default is false.

  5. task.digest - Set to true if you want to include a file digest in the file name of generated assets. Default is false.

  6. task.environment - Set custom sprockets environment.

You can also customize the sprockets environment in the block to configure additional preprocessors or compressors.

Note: Sprockets-standalone will always use a manifest.json even when asset digests are turned off. The manifest.json will be used to track changes. If you manually change the generated assets that will not be override when compiling assets unless there is also a change if the matching source files. You will need to remove generated assets (rake assets:clobber) to force regeneration of all assets.

Contributing

  1. Fork it ( http://github.com/jgraichen/sprockets-standalone/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

sprockets-standalone's People

Contributors

jgraichen avatar

Watchers

James Cloos avatar  avatar

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.