Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created April 18, 2017 15:22
Show Gist options
  • Select an option

  • Save barraponto/d7b1ed410f5ec7ccb574e40fd21faf39 to your computer and use it in GitHub Desktop.

Select an option

Save barraponto/d7b1ed410f5ec7ccb574e40fd21faf39 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 = styleRule && styleRule.use('style');
const styleLoaders = styleRule && styleRule.uses.store.keys()
.filter((key) => key !== 'style')
.map((key) => stylerule.use(key))
.map((use) => ({loader: use.loader, options: use.options}));
const loaders = ExtractTextPlugin.extract({
fallback: options.fallback || styleFallback|| 'style-loader',
use: options.use || styleLoaders || 'css-loader',
});
loaders.forEach((loader, options) => console.log([loader, options]));
neutrino.config.plugin('extract')
.use(ExtractTextPlugin, [options.filename || '[name].css']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment