Search code examples
asp.net-mvcwebpackasp.net-mvc-5

MVC 5 - include WebPack output into publish


I am using MVC 5 with WebPack.

I have a "/dist" folder in my web project which is empty, but during compile I invoke WebPack and it creates output files for me. "/dest" will be populated with files which WebPack has created for me.

/dist
  /dist/script1.js
  /dist/script2.js
  etc...

How can I ensure that the "/dist" folder and all of its files are included in the publish output?

The web project publishes just fine, but the /dist folder is missing from it.

Including the files into the solution doesn't seem like the right answer. Is there a better way?


Solution

  • You can add the dist folder to the project by adding to the csproj file :

    <ItemGroup>
        <Content Include="dist/**" />
    </ItemGroup>
    

    this will include the dist folder and all its files in the project, and since it's declared as content it will also be included in the deployement.