@flatjs/forge-plugin-postcss-assets
v1.7.2
Published
A plugin for PostCSS that used to base64, copy assets on url()
Downloads
12
Maintainers
Readme
The flatjs plugin @flatjs/forge-plugin-postcss-assets
Features
A plugin for PostCSS that used to base64, copy assets on url()
Installation
npm i --save @flatjs/forge-plugin-postcss-assets
Usage
图片压缩优化
brew install libpng
import imageminJpegtran from 'imagemin-jpegtran';
import imageminPngquant from 'imagemin-pngquant';
programing
import { forgePluginPostcssAssets } from '@flatjs/forge-plugin-postcss-assets';
import postcss from 'postcss';
export function processedCss(
fixtures: string,
urlOpts: PostcssAssetsUrlOptions<'default'>,
postcssOpts?: ProcessOptions,
): Promise<string> {
return postcss()
.use(forgePluginPostcssAssets(urlOpts))
.process(read(fixtures), postcssOpts)
.then((res) => res.css);
}
const css = await processedCss('fixtures/inline-fonts', {}, postcssOpts);
expect(css).toEqual(expect.stringMatching(/;base64/));
Using with @flatjs/forge
Please see samples of @flatjs/forge-plugin-styling
# Reference
- [postcss playground](https://sneakertack.github.io/postcss-playground/)