【发布时间】:2020-08-13 11:21:53
【问题描述】:
我的 webpack 配置如下
const webdirectory = "../Application/Web"
plugins: [
new HtmlWebpackPlugin({
inject: "body",
filename: `${webdirectory}/Views/Health/Index.cshtml`,
template: `${webdirectory}/Views/Health/Index_Template.cshtml`,
minify: false
}),
output: {
// assets served by webpack-dev-server
path: path.resolve(__dirname, "IGNOREdevjunk/"),
publicPath: "https://localhost:8080/"
},
我希望 webpack 在与获取模板的文件夹相同的文件夹中生成 cshtml。但是 webpack 做了什么,它从正确的位置抓取模板,但是当它保存 cshtml 时,它完全弄乱了输出目录。它所做的是获取“路径”变量 VALUE,在本例中为“客户端”,然后在 Client/IGNOREdevjunk/Application/Web/Views/Health/Index.cshtml 中创建 cshtml
如何让它将 cshtml 保存在与模板相同的文件夹中?保存时忽略相对路径。
目录结构
Parent
- Application
- - Web
- - - Views
- - - - Health
- - - - - Index_template.cshtml
- - - - - Index.cshtml (THIS IS WHERE I WANT THE CSHTML TO BE EMITTED)
- Client
- webpack.config.js
- - IGNOREdevjunk
- - - Application
- - - - Web
- - - - - Views
- - - - - - Health
- - - - - - Index.cshtml (I DON'T WANT THIS SAVED HERE)
【问题讨论】:
标签: file webpack output html-webpack-plugin