Sha256: b32c00394178985afc8753de28cb8fc4a07900ddfb1465fbcffc41aee6929eef
Contents?: true
Size: 807 Bytes
Versions: 9
Compression:
Stored size: 807 Bytes
Contents
import { execSync } from 'child_process'; const plugin = (opts = {}) => { return { postcssPlugin: 'postcss-gem-import', Once(root) { root.walkAtRules('import', (rule) => { const importPath = rule.params.replace(/['"]/g, ''); if (importPath.startsWith('gem:')) { const gemName = importPath.split('gem:')[1].split('/')[0]; try { const gemPath = execSync(`bundle show ${gemName}`, { encoding: 'utf8' }).trim(); const newPath = importPath.replace(`gem:${gemName}`, gemPath); rule.params = `"${newPath}"`; } catch (error) { throw rule.error(`Failed to resolve gem path for ${gemName}: ${error.message}`); } } }); } }; }; plugin.postcss = true; export default plugin;
Version data entries
9 entries across 9 versions & 1 rubygems