npm install --save-dev raw-content-replace-loader
Use the loader either via your webpack config, CLI or inline.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: require.resolve('raw-content-replace-loader'),
options: {
// include: /rdoc\.tree\.data\.json$/, // 检查包含的文件名字
// extensions: /\.md/,
path: PATH.join(cachePath, './md'), // 需要替换的目录
replace: cmd.projectRoot, // 替换成目标目录
sep: /___/g, // 文件名存储,文件夹+下划线间隔+文件名
}
}
]
}
]
}
}