@kkt/raw-modules
Version:
Makes it easy to use the webpack raw-loader.
32 lines (31 loc) • 941 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Makes it easy to use the webpack raw-loader
*/
const rawModules = (conf, env, options = {}) => {
if (!conf) {
throw Error('KKT:ConfigPaths: there is no config file found');
}
const { test = /\.md$/i, esModule = true } = options;
const loaders = [
{
test,
use: [
{
loader: require.resolve('raw-loader'),
options: { esModule },
},
],
},
];
// Exclude all less files (including module files) from file-loader
conf.module.rules = conf.module?.rules?.map((rule) => {
if (rule && typeof rule === 'object' && rule.oneOf && Array.isArray(rule.oneOf)) {
rule.oneOf = [...loaders, ...rule.oneOf];
}
return rule;
});
return conf;
};
exports.default = rawModules;