PostCSS plugin for obuild
npm install @obuild/plugin-postcssPostCSS plugin for obuild.
This plugin integrates the PostCSS processor into the obuild build system, allowing you to transform CSS files using PostCSS plugins.
Import the plugin in your build configuration and add it to the plugins array. You can also configure it with options.
``ts
import { defineBuildConfig } from "obuild/config";
import { postcss } from "@obuild/plugin-postcss";
export default defineBuildConfig({
entries: [
{
type: "transform",
input: "./src/runtime/",
outDir: "./dist/runtime/",
plugins: [
postcss({
// Configuration options
}),
],
},
],
});
`
The following interface describes the options you can pass to the plugin:
`ts [options.ts]
import type { Config, Extensions } from "./config.ts";
import type { AssetFile, InputFile, PluginContext } from "obuild";
import type { Options as PostcssNestedOptions } from "postcss-nested";
import type { Options as AutoprefixerOptions } from "autoprefixer";
import type { Options as CssnanoOptions } from "cssnano";
import type {
AcceptedPlugin as PostcssPlugin,
ProcessOptions as PostcssProcessOptions,
} from "postcss";
export interface PostcssPluginOptions {
/* File extensions that this plugin should process. /
extensions?: Extensions;
/* PostCSS process options. /
processOptions?: Omit
/* Nested plugin options or false to disable nested processing. /
nested?: false | PostcssNestedOptions;
/* Autoprefixer options or false to disable autoprefixing. /
autoprefixer?: false | AutoprefixerOptions;
/* Cssnano options or false to disable minification. /
cssnano?: false | CssnanoOptions;
/* PostCSS plugins to use in addition to the built-in ones. /
plugins?: PostcssPlugin[];
/**
* Configuration hook that allows you to modify the configuration for a
* specific file.
*
* @param file - The input file.
* @param config - The current configuration for the plugin.
* @param context - The plugin context.
* @returns Modified configuration or undefined if the file should not be
* processed.
*/
fileConfig?: (
file: InputFile | AssetFile,
config: Config,
context: PluginContext,
) => Config | undefined;
}
``
š Released under the MIT license.
---
_š¤ auto updated with automd_