"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/cssnano/src/index.js" between
cssnano-cssnano-5.0.6.tar.gz and cssnano-cssnano-5.0.7.tar.gz

About: cssnano is a modular CSS minifier (built on top of the PostCSS ecosystem).

index.js  (cssnano-cssnano-5.0.6):index.js  (cssnano-cssnano-5.0.7)
import path from 'path'; import path from 'path';
import postcss from 'postcss'; import postcss from 'postcss';
import { cosmiconfigSync } from 'cosmiconfig'; import yaml from 'yaml';
import { lilconfigSync } from 'lilconfig';
import isResolvable from 'is-resolvable'; import isResolvable from 'is-resolvable';
const cssnano = 'cssnano'; const cssnano = 'cssnano';
/* /*
* preset can be one of four possibilities: * preset can be one of four possibilities:
* preset = 'default' * preset = 'default'
* preset = ['default', {}] * preset = ['default', {}]
* preset = function <- to be invoked * preset = function <- to be invoked
* preset = {plugins: []} <- already invoked function * preset = {plugins: []} <- already invoked function
skipping to change at line 62 skipping to change at line 63
} }
// If all else fails, we probably have a typo in the config somewhere // If all else fails, we probably have a typo in the config somewhere
throw new Error( throw new Error(
`Cannot load preset "${fn}". Please check your configuration for errors and try again.` `Cannot load preset "${fn}". Please check your configuration for errors and try again.`
); );
} }
/* /*
* cssnano will look for configuration firstly as options passed * cssnano will look for configuration firstly as options passed
* directly to it, and failing this it will use cosmiconfig to * directly to it, and failing this it will use lilconfig to
* load an external file. * load an external file.
*/ */
function resolveConfig(options) { function resolveConfig(options) {
if (options.preset) { if (options.preset) {
return resolvePreset(options.preset); return resolvePreset(options.preset);
} }
let searchPath = process.cwd(); let searchPath = process.cwd();
let configPath = null; let configPath = null;
if (options.configFile) { if (options.configFile) {
searchPath = null; searchPath = null;
configPath = path.resolve(process.cwd(), options.configFile); configPath = path.resolve(process.cwd(), options.configFile);
} }
const configExplorer = cosmiconfigSync(cssnano); const configExplorer = lilconfigSync(cssnano, {
searchPlaces: [
'package.json',
'.cssnanorc',
'.cssnanorc.json',
'.cssnanorc.yaml',
'.cssnanorc.yml',
'.cssnanorc.js',
'cssnano.config.js',
],
loaders: {
'.yaml': (filepath, content) => yaml.parse(content),
'.yml': (filepath, content) => yaml.parse(content),
},
});
const config = configPath const config = configPath
? configExplorer.load(configPath) ? configExplorer.load(configPath)
: configExplorer.search(searchPath); : configExplorer.search(searchPath);
if (config === null) { if (config === null) {
return resolvePreset('default'); return resolvePreset('default');
} }
return resolvePreset(config.config.preset || config.config); return resolvePreset(config.config.preset || config.config);
} }
 End of changes. 3 change blocks. 
3 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)