1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Update postcss.js documentation

This commit is contained in:
Chauncey McAskill
2022-10-13 14:42:50 -04:00
parent 9db0c71a82
commit 89bb00790f

View File

@@ -11,6 +11,10 @@
* @typedef {import('postcss').AcceptedPlugin} AcceptedPlugin * @typedef {import('postcss').AcceptedPlugin} AcceptedPlugin
*/ */
/**
* @typedef {import('postcss').Postcss} Postcss
*/
/** /**
* @typedef {import('postcss').ProcessOptions} ProcessOptions * @typedef {import('postcss').ProcessOptions} ProcessOptions
*/ */
@@ -38,6 +42,10 @@
* @property {AutoprefixerOptions} autoprefixer - The `autoprefixer()` options. * @property {AutoprefixerOptions} autoprefixer - The `autoprefixer()` options.
*/ */
/**
* @type {Postcss|undefined} postcss - The discovered PostCSS function.
* @type {AcceptedPlugin|undefined} autoprefixer - The discovered Autoprefixer function.
*/
let postcss, autoprefixer; let postcss, autoprefixer;
try { try {
@@ -50,11 +58,21 @@ try {
// do nothing // do nothing
} }
/**
* @type {boolean} Whether PostCSS was discovered (TRUE) or not (FALSE).
*/
const supportsPostCSS = (typeof postcss === 'function'); const supportsPostCSS = (typeof postcss === 'function');
/**
* @type {PluginList} A list of supported plugins.
*/
const pluginsList = [ const pluginsList = [
autoprefixer, autoprefixer,
]; ];
/**
* @type {PluginMap} A map of supported plugins.
*/
const pluginsMap = { const pluginsMap = {
'autoprefixer': autoprefixer, 'autoprefixer': autoprefixer,
}; };
@@ -62,10 +80,11 @@ const pluginsMap = {
/** /**
* Attempts to create a PostCSS Processor with the given plugins and options. * Attempts to create a PostCSS Processor with the given plugins and options.
* *
* @param {PluginCollection} pluginsListOrMap - A list or map of plugins. * @param {PluginCollection} pluginsListOrMap - A list or map of plugins.
* If a map of plugins, the plugin name looks up `options`. * If a map of plugins, the plugin name looks up `options`.
* @param {PostCSSOptions} options - The PostCSS wrapper options. * @param {PostCSSOptions} options - The PostCSS wrapper options.
* @return {?Processor} *
* @returns {Processor|null}
*/ */
function createProcessor(pluginsListOrMap, options) function createProcessor(pluginsListOrMap, options)
{ {
@@ -81,10 +100,11 @@ function createProcessor(pluginsListOrMap, options)
/** /**
* Parses the PostCSS plugins and options. * Parses the PostCSS plugins and options.
* *
* @param {PluginCollection} pluginsListOrMap - A list or map of plugins. * @param {PluginCollection} pluginsListOrMap - A list or map of plugins.
* If a map of plugins, the plugin name looks up `options`. * If a map of plugins, the plugin name looks up `options`.
* @param {PostCSSOptions} options - The PostCSS wrapper options. * @param {PostCSSOptions} options - The PostCSS wrapper options.
* @return {PluginList} *
* @returns {PluginList}
*/ */
function parsePlugins(pluginsListOrMap, options) function parsePlugins(pluginsListOrMap, options)
{ {