![]() To use this feature in your Gulp file, install it using NPM 1 Useref sees the build token and creates a css file named combined.css and a JavaScript file named combined.js and changes the output html so that it looks like this: 1 Your HTML file would look something like this: 1 This module lets us put tokens in our html file that specify which files we want to compress and what the resulting file name should be. Like I said, there are many ways of bundling JavaScript and CSS code, but the way I’ve found that seems to have the least amount of work involved is by using the gulp-useref module. So all of my development work will be done in. If you are working in some other environment, I’m sure you have some kind of similar way of specifying the default file based on an environment setting. Since I’m working with a single page application (SPA), this was a simple matter of configuring my default file to be for development and and using web.config transforms to specify which should be used in which environment. There are several ways that you might do this, but what I wanted was some way that would allow me to work unbundled during development and bundled when I released the code. The first thing we want to do is that we want to combine all of our CSS files and JavaScript files into one file for CSS and one file for JavaScript. So if you are using some other technology, you’ll still benefit from this article. But the Gulp file I am going to walk you through is technology agnostic. Since most of the people who read this blog are ASP.NET developers, there may be a few. So, if you don’t already have Node.js and Gulp installed, you may want to go back and read the article I wrote last week. This week, my intent is to walk you through exactly how I do that. ![]() During that discussion, I mentioned that I’m using gulp to bundle, minify and cache-bust my HTML, CSS, and JavaScript files. Last week I discussed how to setup Node.js and Gulp in Visual Studio 2015.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |