pub struct Browsers {
    pub android: Option<u32>,
    pub chrome: Option<u32>,
    pub edge: Option<u32>,
    pub firefox: Option<u32>,
    pub ie: Option<u32>,
    pub ios_saf: Option<u32>,
    pub opera: Option<u32>,
    pub safari: Option<u32>,
    pub samsung: Option<u32>,
}
Expand description

Browser versions to compile CSS for.

Versions are represented as a single 24-bit integer, with one byte per major.minor.patch component.

Example

This example represents a target of Safari 13.2.0.

use lightningcss::targets::Browsers;

let targets = Browsers {
  safari: Some((13 << 16) | (2 << 8)),
  ..Browsers::default()
};

Fields§

§android: Option<u32>§chrome: Option<u32>§edge: Option<u32>§firefox: Option<u32>§ie: Option<u32>§ios_saf: Option<u32>§opera: Option<u32>§safari: Option<u32>§samsung: Option<u32>

Implementations§

source§

impl Browsers

source

pub fn from_browserslist<S: AsRef<str>, I: IntoIterator<Item = S>>( query: I ) -> Result<Option<Browsers>, Error>

Available on crate feature browserslist only.

Parses a list of browserslist queries into Lightning CSS targets.

source

pub fn load_browserslist() -> Result<Option<Browsers>, Error>

Available on crate feature browserslist only.

Finds browserslist configuration, selects queries by environment and loads the resulting queries into LightningCSS targets.

Configuration resolution is modeled after the original browserslist nodeJS package. The configuration is resolved in the following order:

  • If a BROWSERSLIST environment variable is present, then load targets from its value. This is analog to the --targets CLI option. Example: BROWSERSLIST="firefox ESR" lightningcss [OPTIONS] <INPUT_FILE>
  • If a BROWSERSLIST_CONFIG environment variable is present, then resolve the file at the provided path. Then parse and use targets from package.json or any browserslist configuration file pointed to by the environment variable. Example: BROWSERSLIST_CONFIG="../config/browserslist" lightningcss [OPTIONS] <INPUT_FILE>
  • If none of the above apply, then find, parse and use targets from the first browserslist, .browserslistrc or package.json configuration file in any parent directory.

When using parsed configuration from browserslist, .browserslistrc or package.json configuration files, the environment determined by:

  • the BROWSERSLIST_ENV environment variable if present,
  • otherwise the NODE_ENV environment varialbe if present,
  • otherwise production is used.

If no targets are found for the resulting environment, then the defaults configuration section is used.

Trait Implementations§

source§

impl Clone for Browsers

source§

fn clone(&self) -> Browsers

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Browsers

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Browsers

source§

fn default() -> Browsers

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Browsers

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Browsers

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Browsers

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,