"use strict"; const postcss = require("postcss"); const defaultValue = require("default-value"); const postcssValues = require("postcss-modules-values"); const postcssLocalByDefault = require("postcss-modules-local-by-default"); const postcssExtractImports = require("postcss-modules-extract-imports"); const postcssScope = require("postcss-modules-scope"); const genericNames = require("generic-names"); const postcssFindImports = require("./postcss-icss-find-imports"); module.exports = function createFilePreprocessor(options) { let generateScopedName = defaultValue(options.generateScopedName, genericNames("[name]__[local]---[hash:base64:5]")); let postcssInstance = postcss([ ... defaultValue(options.before, []), postcssValues, postcssLocalByDefault({ mode: defaultValue(options.mode, "local") }), postcssExtractImports(), postcssScope({ generateScopedName: generateScopedName }), postcssFindImports() ]); return function preprocessFile(item) { return postcssInstance.process(item.source, { from: item.file, ... options }); }; };