v1.0 with SW PWA enabled

This commit is contained in:
Blomios
2026-01-01 17:40:53 +01:00
parent 1c0e22aac1
commit 3c8bebb2ad
29775 changed files with 2197201 additions and 119080 deletions

View File

@ -1,5 +1,4 @@
'use strict'
// @ts-check
const req = require('./req.js')
/**
@ -11,21 +10,24 @@ const req = require('./req.js')
* @param {String} plugin PostCSS Plugin Name
* @param {Object} options PostCSS Plugin Options
*
* @return {Function} PostCSS Plugin
* @return {Promise<Function>} PostCSS Plugin
*/
const load = (plugin, options, file) => {
async function load(plugin, options, file) {
try {
if (
options === null ||
options === undefined ||
Object.keys(options).length === 0
) {
return req(plugin, file)
return await req(plugin, file)
} else {
return req(plugin, file)(options)
return (await req(plugin, file))(options)
/* c8 ignore next */
}
} catch (err) {
throw new Error(`Loading PostCSS Plugin failed: ${err.message}\n\n(@${file})`)
throw new Error(
`Loading PostCSS Plugin failed: ${err.message}\n\n(@${file})`
)
}
}
@ -37,25 +39,26 @@ const load = (plugin, options, file) => {
*
* @param {Object} config PostCSS Config Plugins
*
* @return {Array} plugins PostCSS Plugins
* @return {Promise<Array>} plugins PostCSS Plugins
*/
const plugins = (config, file) => {
let plugins = []
async function plugins(config, file) {
let list = []
if (Array.isArray(config.plugins)) {
plugins = config.plugins.filter(Boolean)
list = config.plugins.filter(Boolean)
} else {
plugins = Object.keys(config.plugins)
.filter((plugin) => {
return config.plugins[plugin] !== false ? plugin : ''
list = Object.entries(config.plugins)
.filter(([, options]) => {
return options !== false
})
.map((plugin) => {
return load(plugin, config.plugins[plugin], file)
.map(([plugin, options]) => {
return load(plugin, options, file)
})
list = await Promise.all(list)
}
if (plugins.length && plugins.length > 0) {
plugins.forEach((plugin, i) => {
if (list.length && list.length > 0) {
list.forEach((plugin, i) => {
if (plugin.default) {
plugin = plugin.default
}
@ -67,19 +70,20 @@ const plugins = (config, file) => {
}
if (
// eslint-disable-next-line
!(
(typeof plugin === 'object' && Array.isArray(plugin.plugins)) ||
(typeof plugin === 'object' && plugin.postcssPlugin) ||
(typeof plugin === 'function')
typeof plugin === 'function'
)
) {
throw new TypeError(`Invalid PostCSS Plugin found at: plugins[${i}]\n\n(@${file})`)
throw new TypeError(
`Invalid PostCSS Plugin found at: plugins[${i}]\n\n(@${file})`
)
}
})
}
return plugins
return list
}
module.exports = plugins