A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.org/package/postcss-custom-url below:

postcss-custom-url - npm

postcss-custom-url

Transform url() in css.

Usage

var url = require('postcss-custom-url')

var util = url.util

 

var postcss = require('postcss')

var path = require('path')

var fixtures = path.resolve.bind(path, __dirname, 'fixtures')

 

postcss(url([

  [ util.inline, { maxSize: 5 } ],

  

  [ 'copy', { assetOutFolder: fixtures('build', 'images') } ],

]))

.process(

  '.a{ background-image: url(images/octocat_setup.png); }',

  { from: fixtures('a.css'), to: fixtures('build', 'css', 'a.css') }

)

.then(function (result) {

  console.log(result.css)

  

})

 

url(customTransforms) customTransforms

Type: Array

Default: [ util.rebase ]

An array of transforms.

If an element is not a function, it should be the name of a method exported by util: 'copy', 'inline', 'rebase'.

transforms

Type: Function, Array

Signature: transformFn(result, ...args)

Function to transform url, through modifying result.url

If Array, the first element should be the transform function, and elements after the first will be treated as its arguments args.

result

Type: Result

Result

Properties and methods:

Asset

Properties and methods:

util

A group of transform methods.

rebase

Transform result.url according to result.to

inline

Transform result.url to data-url.

Options:

copy

Copy asset files to proper destinations and transform result.url.

Options:

var url = require('postcss-custom-url')

var postcss = require('postcss')

 

postcss(url([

  [

    'copy',

    {

      

      

      

      assetOutFolder: '/path/to/build/images',

 

      

      name: '[name].[hash]',

 

      

      

 

      

      

    },

  ],

]))

.process(

  '.a{ background-image: url(images/octocat_setup.png); }',

  { from: '/path/to/src/style.css', to: '/path/to/build/css/style.css' }

)

.then(function (result) {

  console.log(result.css)

  

})

 


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4