Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created April 18, 2017 15:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barraponto/0f1b28769e824f29c54d827fa9b4b5f9 to your computer and use it in GitHub Desktop.
Save barraponto/0f1b28769e824f29c54d827fa9b4b5f9 to your computer and use it in GitHub Desktop.
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']);
};
@kirikintha
Copy link

kirikintha commented Apr 24, 2017

Just wanted to give you a shout out that this worked so well! I can convert .scss to .css with neutrino no problem.

@leesiongchan
Copy link

Why not publish it?

@barraponto
Copy link
Author

@leesiongchan it is published here :)

@barraponto
Copy link
Author

@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