Last active
September 9, 2015 15:34
-
-
Save aaronj1335/76f4bf247b062c7cae9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import postcss from 'postcss'; | |
| import customProperties from 'postcss-custom-properties'; | |
| import {reduce} from 'lodash'; | |
| import LineToLineMappedSource from 'webpack-core/lib/LineToLineMappedSource'; | |
| export default function() { | |
| this.plugin('compilation', function(compilation) { | |
| compilation.plugin('optimize-chunk-assets', function(chunks, callback) { | |
| compilation.assets = reduce(compilation.assets, (assets, asset, name) => { | |
| if (/\.css$/.test(name)) { | |
| var resolvedCss = postcss() | |
| .use(customProperties()) | |
| .process(asset.source()) | |
| .css; | |
| assets[name] = new LineToLineMappedSource(resolvedCss, name, asset.source()); | |
| } else | |
| assets[name] = asset; | |
| return assets; | |
| }, compilation.assets); | |
| callback(); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment