Commit 9d1b0d05 authored by Dan Allen's avatar Dan Allen
Browse files

merge !116

resolves #112 unmangle pseudo-element selectors
parents 3c8aaccb 7fe0510a
......@@ -24,7 +24,7 @@ module.exports = (src, dest, preview) => () => {
const sourcemaps = preview || process.env.SOURCEMAPS === 'true'
const postcssPlugins = [
postcssImport,
(root, { messages, opts: { file } }) =>
(css, { messages, opts: { file } }) =>
Promise.all(
messages
.reduce((accum, { file: depPath, type }) => (type === 'dependency' ? accum.concat(depPath) : accum), [])
......@@ -49,7 +49,9 @@ module.exports = (src, dest, preview) => () => {
postcssVar({ preserve: preview }),
preview ? postcssCalc : () => {},
autoprefixer,
preview ? () => {} : cssnano({ preset: 'default' }),
preview
? () => {}
: (css, result) => cssnano({ preset: 'default' })(css, result).then(() => postcssPseudoElementFixer(css, result)),
]
return merge(
......@@ -111,3 +113,9 @@ module.exports = (src, dest, preview) => () => {
vfs.src('partials/*.hbs', opts)
).pipe(vfs.dest(dest, { sourcemaps: sourcemaps && '.' }))
}
function postcssPseudoElementFixer (css, result) {
css.walkRules(/(?:^|[^:]):(?:before|after)/, (rule) => {
rule.selector = rule.selectors.map((it) => it.replace(/(^|[^:]):(before|after)$/, '$1::$2')).join(',')
})
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment