diff --git a/package.json b/package.json index da482d6b2..c564f95f8 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "// postcss-preset-env": "Using bleeding edge because https://github.com/csstools/postcss-plugins/issues/481#issuecomment-1334903391", "postcss-replace": "To edit relative paths to fonts" }, - "devDependencies": { + "peerDependencies": { "@frctl/fractal": "^1.5.15", "@frctl/handlebars": "^1.2.15", "@frctl/mandelbrot": "^1.10.1", diff --git a/src/.postcssrc.base.yml b/src/.postcssrc.base.yml index 85e9d02b5..40014f643 100644 --- a/src/.postcssrc.base.yml +++ b/src/.postcssrc.base.yml @@ -1,7 +1,5 @@ plugins: - postcss-import: - path: - - 'src/lib' + postcss-import: {} postcss-extend: {} # DEPRECATED diff --git a/src/bin/config.js b/src/bin/config.js index d6c3e0365..29efaf5d9 100755 --- a/src/bin/config.js +++ b/src/bin/config.js @@ -55,8 +55,9 @@ function config(customConfigFiles = [], cssVersion) { }); const mergedJson = merge(...configObjects); - // Update version property - const updatedJson = updateVersion(mergedJson, cssVersion); + // Update properties + let updatedJson = updateVersion(mergedJson, cssVersion); + updatedJson = resolveImportFromPaths(updatedJson); const configYaml = yaml.dump(updatedJson); // Write final config file @@ -77,6 +78,38 @@ function updateVersion(config, version) { return config; } +/** + * Update the value for the CSS version in given config data + * @param {object} config - The config data in which to update the version + * @return {object} - Updated config + */ +function resolveImportFromPaths(config) { + let paths = config['plugins']['postcss-env-function']['importFrom']; + paths = (typeof paths === 'string') ? [ paths ] : paths; + let newPaths = []; + + console.log(`Resolving 'importFrom' paths`); + + if (paths) { + paths.forEach(path => { + let newPath; + try { + newPath = require.resolve(path); + } catch { + newPath = path; + } finally { + newPaths.push( newPath ); + } + }); + } else { + newPaths = paths; + } + + config['plugins']['postcss-env-function']['importFrom'] = newPaths; + + return config; +} + /** * Get JSON from YAML config file * @param {string} filePath - YAML config file