borodean / postcss-assets

An asset manager for PostCSS
MIT License
537 stars 32 forks source link

Source property of node can be undefined #29

Closed OEvgeny closed 8 years ago

OEvgeny commented 9 years ago

Related to discussion in OEvgeny/postcss-assets@498281cc97 I found that your plugin depends on source property of each node. Some plugins don't include it in created rules (see: jonathantneal/postcss-font-magician#9). I don't know the right way to work around of this issue. May be we shall call @ai for clarification. Should each node contain source property or not?

ai commented 9 years ago

Let’s print error, that we can’t understant .

OEvgeny commented 9 years ago

Sorry. I get this:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
TypeError: Cannot read property 'input' of undefined
    at /app/node_modules/postcss-assets/index.js:222:33
    at /app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:88:34
    at /app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:73:26
    at AtRule.each (/app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:59:22)
    at AtRule.walk (/app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:72:21)
    at /app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:76:32
    at Root.each (/app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:59:22)
    at Root.walk (/app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:72:21)
    at Root.walkDecls (/app/node_modules/gulp-postcss/node_modules/postcss/lib/container.js:86:25)
    at Assets.postcss (/app/node_modules/postcss-assets/index.js:219:7)
    at LazyResult.run (/app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:201:20)
    at /app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:115:37
    at LazyResult.asyncTick (/app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:129:15)
    at /app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:127:27
    at LazyResult.asyncTick (/app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:129:15)
    at processing.Promise.then._this2.processed (/app/node_modules/gulp-postcss/node_modules/postcss/lib/lazy-result.js:155:20)

I'm using both of plugins postcss-font-magician and postcss-assets. My config:

  var preprocess = [
    font({//postcss-font-magician
      hosted: '../fonts',
      formats: 'woff2 woff'
    }),
    assets({//postcss-assets
      basePath: 'src/'
    }),
    autoprefixer({
      browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']
    })
  ]

When I swap font and assets it's working as expected. So, for some reason rules that was created by postcss-font-magician not contain source property therefore it causes this error.

borodean commented 8 years ago

@OEvgeny sorry for a late reply. Currently I'm trying to reproduce the issue but I can't. Could you please verify that this still occurs on the latest versions of postcss, postcss-assets and postcss-font-magician?

OEvgeny commented 8 years ago

Seems I can't reproduce it with newer versions too. So, closing this for now.