How to use the postcss-load-config.catch function in postcss-load-config

To help you get started, we’ve selected a few postcss-load-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github upash / peco / lib / index.js View on Github external
async prepare({ dev }) {
    console.log('> Building from source')
    // Load user config
    const { data, path: configPath } = await config.load(
      [
        'peco.config.yml',
        'peco.config.toml',
        'peco.config.js',
        'peco.config.json'
      ],
      this.options.baseDir
    )
    this.configPath = configPath
    await this.normalizeConfig(data)

    const postcssConfig = await require('postcss-load-config')({
      cwd: this.options.baseDir,
      argv: false
    }).catch(err => {
      if (err.message.includes('No PostCSS Config found')) {
        // Return empty options for PostCSS
        return {}
      }
      throw err
    })

    if (postcssConfig.file) {
      this.postcss = {
        config: {
          path: postcssConfig.file
        }
      }

postcss-load-config

Autoload Config for PostCSS

MIT
Latest version published 2 days ago

Package Health Score

89 / 100
Full package analysis