3
對於我們的項目,我們正在開發適用於角度2應用程序的mvc 5應用程序。對於捆綁,我們使用Webpack。用於混合cshtml和html的Webpack配置(角度2 + mvc)
現在的問題是,一些組件必須使用呈現cshtml視圖的mvc控制器加載html。對於其他組件,我們使用靜態HTML文件。
我想配置Webpack,以便將「靜態」組件html作爲內嵌html呈現在組件中,並且templateUrl保留用於需要動態呈現html的組件。
這是我嘗試過的許多事情之一,但我無法得到包括和排除工作。應用程序組件需要服務器呈現的cshtml。
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader'], // here i want to inline the html
exclude: ["/client/src/app/app.component.ts"]
},
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader'], // here i want to keep the templateUrl so that the cshtml can be rendered
include: ["/client/src/app/app.component.ts"]
},
您是否設法解決這個問題? – jkyadav
@jkyadav是的我認識到包括和排除期望的正則表達式解決了這個問題。所以我用exclude排除了它:/!?app\.component.ts$/ – Jensdc
謝謝,我會看看 – jkyadav