IT:AD:gulp:HowTo:Integrate With Visual Studio
Summary
Visual Studio has seen the rise of IT:AD:Grunt and IT:AD:Gulp and has decided to integrate them into Visual Studio and IT:AD:Code.
But of course…you can't marry such disparate bed partners without some hitches.
Process
Root Package Folder
For one, there's the difference as to where the root package folder (where the package.json file lives).
For a js approach, the root folder is the parent of the app/ folder. Something like:
app/ <-- both the project root and local package root folder
src/
controllers/
css/
images/
scripts/
dist/
controllers/
css/
images/
scripts/
package.json
Whereas in Visual Studio, the package.json file is one deeper
solution/ <-- local package root folder
app/ <-- both the project root
src/
controllers/
css/
images/
scripts/
dist/
controllers/
css/
images/
scripts/
package.json
Since node.js packages are invariably written for the first scenario…things need sorting out.
Gulp File
Not only is the package.json file's location an issue, but Visual Studio has the same issue with the gulpfile.js – it expects to find it in the project root directory – not the app/ directory.
Getting rid of the webroot folder
Turns out that there is a way to get rid of the wwwroot folder (or app folder if you've renamed it) altogether.
The steps are described here and basically involve doing the following:
- first, you have to set the
hosting.json'swebrootvalue to nothing
- hosting.json
{ "webroot": "" }
- then you have to actually removing the
wwwrootfolder, moving all it's contents down to the project root.
Separate Project for Client Work
For as long as ASP.MVC was around we've been used to serving client side html from some form of server-side project. In other words, our presentation projects were always a mish-mash of server-side controllers and static html, css, and images.
I'm going to recommend that you don't.
Instead, cut a new project for client code only.