const path = require('path');
const hook = require('css-modules-require-hook');
const stylus = require('stylus');

hook({
  generateScopedName: '[name]_[local]__[hash:base64:5]',
  extensions: ['.styl'],
  preprocessCss: function (css, filename) {
    return stylus(css)
      .set('filename', filename)
      .render();
  }
});

module.exports = (sections, meta, callback) => {
  var styles = require(path.join(meta.theme, '/assets/styles/index.styl'));
  meta.cssMap = styles;
  callback(null, sections);
}