Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-rails-asset-urls

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-rails-asset-urls

PostCSS plugin that swaps out CSS urls for Rails asset helpers.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

PostCSS Rails Asset URLs

PostCSS plugin to swap CSS URLs with the appropriate sass-rails helper. This is useful for CSS postprocessor compilation outside of the Rails pipeline when you still want to deploy assets through Rails. These helpers, when used in the Rails pipeline, will handle fingerprinting and asset paths for you as part of the normal Rails compilation.

Installation

Install via npm:

npm install --save-dev postcss-rails-asset-urls

Use

The post-css plugin function provided by this package takes an argument of the version of sass-rails that you are currently using. If this version is major version 4 or greater, it will replace all urls with asset-url. If it is under major version 4, it will replace font urls with font-url and image urls with image-url. If an argument is not given, it will default to replacing with asset-url.

Example

var postcss = require('postcss');
var railsAssetUrls = require('postcss-rails-asset-urls');

var css = '@font-face {font-family:Test;src:url("test.woff") format("woff"),url("test.otf") format("otf")}';
console.log(postcss(railsAssetUrls('4.0.0')).process(css).css);

// => '@font-face {font-family:Test;src:asset-url("test.woff") format("woff"),asset-url("test.otf") format("otf")}'

To use with grunt-postcss, add this to your Gruntfile:

postcss: {
  options: {
    processors: [
      require('postcss-rails-asset-urls')('4.0.0')
    ]
  },
  dist: {
    src: 'dist/css/*.css'
  }
}

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ryan Bahniuk

Keywords

FAQs

Package last updated on 15 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc