diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/postcss-fontpath/index.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/postcss-fontpath/index.js')
| -rw-r--r-- | node_modules/postcss-fontpath/index.js | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/node_modules/postcss-fontpath/index.js b/node_modules/postcss-fontpath/index.js deleted file mode 100644 index 2fd38c5e..00000000 --- a/node_modules/postcss-fontpath/index.js +++ /dev/null @@ -1,88 +0,0 @@ -'use strict'; - -var fs = require('fs'), - path = require('path'), - postcss = require('postcss'), - url = require('url'); - -var DEFAULT_OPTS = { - checkFiles: false, - ie8Fix: false, - formats: [ - { type: 'embedded-opentype', ext: 'eot' }, - { type: 'woff2', ext: 'woff2' }, - { type: 'woff', ext: 'woff' }, - { type: 'truetype', ext: 'ttf' }, - { type: 'svg', ext: 'svg'} - ] -}; - -module.exports = postcss.plugin('postcss-fontpath', function(opts) { - - var config = Object.assign({}, DEFAULT_OPTS, opts || {}); - - return function (css) { - // Loop through each @rule - css.walkAtRules('font-face', function(rule) { - - // Loop through each decleration in the rule - rule.walkDecls('font-path', function(decl) { - - // Replace single and double quotes with nothing - var fontPath = decl.value.replace(/"/g, '').replace(/'/g, ''), - fonts = [], - ieHack = false, - ext = ''; - - config.formats.forEach(function(format) { - - if (config.checkFiles) { - // Best guess at where our fonts might be relative to - var basePath = css.source.input.file || process.cwd(), - absoluteFontPath = url.parse(path.resolve(path.dirname(basePath), fontPath) + '.' + format.ext).pathname; - - try { - // Try to see if the font exists - fs.accessSync(absoluteFontPath, fs.F_OK); - } catch (err) { - return; - } - } - - // Set the ext var - ext = format.ext; - - if (ext === 'eot' && config.ie8Fix) { - ieHack = true; - ext = 'eot?#iefix'; - } - - // Add the font to the font-face decl - fonts.push('url("' + fontPath + '.' + ext + '") format(\'' + format.type + '\')'); - }); - - if (fonts.length > 0) { - - // If the EOT exists, add the fallback - if (ieHack && config.ie8Fix) { - decl.cloneBefore({ - prop: 'src', - value: 'url("' + fontPath + '.eot")' - }); - } - - // Implode the rest of the fonts - decl.cloneBefore({ - prop: 'src', - value: fonts.join(',\n ') - }); - } - - // Remove our custom decleration - decl.remove(); - - }); - - }); - }; -}); |
