Created
April 18, 2017 15:51
-
-
Save barraponto/0f1b28769e824f29c54d827fa9b4b5f9 to your computer and use it in GitHub Desktop.
This file contains 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
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = (neutrino, options) => { | |
// Supports neutrino-preset-web and any other preset following this pattern. | |
const styleRule = neutrino.config.module.rule('style'); | |
const styleTest = styleRule.get('test'); | |
const styleFallback = { | |
loader: styleRule.use('style').get('loader'), | |
options: styleRule.use('style').get('options') }; | |
const styleLoaders = Array.from(styleRule.uses.store.keys()) | |
.filter((key) => key !== 'style') | |
.map((key) => styleRule.use(key)) | |
.map((use) => ({loader: use.get('loader'), options: use.get('options')})); | |
const loaders = ExtractTextPlugin.extract({ | |
fallback: options.fallback || styleFallback|| 'style-loader', | |
use: options.use || styleLoaders || 'css-loader', | |
}); | |
styleRule.uses.clear(); | |
loaders.forEach(({loader, options}) => { | |
styleRule.use(loader).loader(loader).options(options); | |
}); | |
neutrino.config.plugin('extract') | |
.use(ExtractTextPlugin, [options.filename || '[name].css']); | |
}; |
Why not publish it?
@leesiongchan it is published here :)
@jaridmargolin @leesiongchan @timkelty @kirikintha can you help try the preset out?
just run yarn add github:barraponto/neutrino-preset-extractstyles
to install from github
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just wanted to give you a shout out that this worked so well! I can convert .scss to .css with neutrino no problem.