0.1.0 • Published 5 years ago

@nsivertsen/svelte-preprocess-postcss v0.1.0

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

svelte-preprocess-postcss

Svelte preprocessor function for PostCSS.

Install

npm install --save-dev @nsivertsen/svelte-preprocess-postcss

Usage

If you're using the Svelte compiler API directly:

import * as svelte from 'svelte';
import postcss from 'svelte-preprocess-postcss';

const processed = await svelte.preprocess(source, {
  style: postcss()
});

If you're using Rollup with rollup-plugin-svelte:

import svelte from 'rollup-plugin-svelte';
import postcss from 'svelte-preprocess-postcss';

export default {
  // ...
  plugins: [
    // ...
    svelte({
      preprocess: {
        style: postcss()
      }
    }),
    // ...
  ],
  // ...
};

API

preprocessorFunction = postcss([context])

svelte-preprocess-postcss cares about the following keys in context:

ValuesDescriptionDefault
useConfigFiletrue, falseWhether to load a PostCSS configuration from disk using postcss-load-configtrue
configFilePathstringThe path to your PostCSS config file. If not given, postcss-load-config will look in the current working directoryundefined

All other keys are passed on to postcss-load-config. It passes the following keys on to PostCSS if provided:

ValuesDescriptionDefault
pluginsarrayArray of PostCSS plugins[]
optionsobjectPostCSS options{}

License

MIT