Skip to content

Commit

Permalink
fix: throw error only when child process exits with error code (#41)
Browse files Browse the repository at this point in the history
fix #40
  • Loading branch information
ramasilveyra committed Oct 10, 2020
1 parent ea48949 commit 220d8d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
7 changes: 7 additions & 0 deletions fixture-postcss-plugin.js
@@ -0,0 +1,7 @@
const postcss = require('postcss')

module.exports = postcss.plugin('postcss-fixture', () => (root) => {
console.warn('warn')
console.error('error')
return root
})
6 changes: 3 additions & 3 deletions index.js
@@ -1,5 +1,5 @@
const { spawnSync } = require('child_process');
const path = require('path');
const { spawnSync } = require('child_process')
const path = require('path')

module.exports = (css, settings) => {
const cssWithPlaceholders = css
Expand All @@ -15,7 +15,7 @@ module.exports = (css, settings) => {
encoding: 'utf8'
})

if (result.stderr) {
if (result.status !== 0) {
if (result.stderr.includes('Invalid PostCSS Plugin')) {
console.error('Next.js 9 default postcss support uses a non standard postcss config schema https://err.sh/next.js/postcss-shape, you must use the interoperable object-based format instead https://nextjs.org/docs/advanced-features/customizing-postcss-config')
}
Expand Down
29 changes: 16 additions & 13 deletions postcss.config.js
@@ -1,15 +1,18 @@
const path = require('path')

module.exports = {
"plugins": {
"postcss-easy-import": {},
"postcss-preset-env": {
"browsers": ['last 2 versions', 'ie >= 10'],
"features": {
"nesting-rules": true,
"color-mod-function": {
unresolved: 'warn'
}
}
plugins: {
'postcss-easy-import': {},
'postcss-preset-env': {
browsers: ['last 2 versions', 'ie >= 10'],
features: {
'nesting-rules': true,
'color-mod-function': {
unresolved: 'warn',
},
},
},
"postcss-spiffing": {}
}
}
'postcss-spiffing': {},
[path.resolve(__dirname, './fixture-postcss-plugin.js')]: {}
},
}

0 comments on commit 220d8d6

Please sign in to comment.