Coder Social home page Coder Social logo

assets's Introduction

pakyow-assets

Asset handling for Pakyow. It's intended to be lightweight and fast in development while providing powerful fingerprinting and caching features for production environments.

In development, assets are compiled on demand. They're recompiled again only if the source changes.

When starting up in production, Pakyow will compile, minify, and fingerprint every asset file. Fingerprinted filenames are automatically handled.

Bundled preprocessors include: js, css, png, gif, jpg, favicon, and sass.

Installation

Place inside your Gemfile

gem 'pakyow-assets'

Run bundle install and restart your app server.

Usage

Place all assets in a app/assets directory. When compiled, assets will mimic the directory structure. During development, all assets will be compiled to a .assets directory. Pakyow will serve requests to all assets when running in a development environment. All assets should be in their original, non-minified state; this makes debugging easier in development.

It's recommended that .assets be excluded from version control.

In production, assets will automatically be minified and fingerprinted when the app boots up. As a developer you don't have to worry about fingerprinting assets or setting cache headers; Pakyow does that for you.

Here are the cache headers that Pakyow sets for fingerprinted assets (mtime is the last modified timestamp of the asset):

headers['Age'] = (Time.now - mtime).to_i
headers['Cache-Control'] = 'public, max-age=31536000'
headers['Vary'] = 'Accept-Encoding'
headers['Last-Modified'] = mtime.httpdate

Non-fingerprinted assets will be served, but without cache headers.

Configuration

Take a look at lib/config.rb for all available options.

Custom Preprocessors

Pakyow Assets can easily be extended to support new asset types. Take a look at the existing preprocessors in lib/preprocessors for examples on how to write your own. Eventually all bundled preprocessors will be moved into their own gem, following the pakyow-{preprocessor-name} convention (e.g. pakyow-sass).

External Asset Stores

Any number of asset stores can be registered:

Pakyow::Config.assets.stores[:store_name] = 'absolute_path_to_store'

Assets from all stores will be compiled together into the app. This is intended to be used when including assets in external libraries.

License

pakyow-assets is released under the MIT License.

assets's People

Contributors

bryanp 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.