Permalink
Browse files

Concatenation and minification

  • Loading branch information...
edwardridge committed Sep 24, 2015
1 parent 1dab9af commit a2a5eb8b4df4457db3c1025d2fb7162d39f0c1af
@@ -124,9 +124,11 @@
<Content Include="favicon.ico" />
<Content Include="fonts\glyphicons-halflings-regular.svg" />
<Content Include="Global.asax" />
<Content Include="gulpfile.js" />
<Content Include="Scripts\Libraries\bootstrap.js" />
<Content Include="Scripts\Libraries\bootstrap.min.js" />
<Content Include="Scripts\Libraries\jquery.js" />
<Content Include="package.json" />
<None Include="Scripts\Libraries\jquery.validate-vsdoc.js" />
<Content Include="Scripts\Libraries\jquery.validate.js" />
<Content Include="Scripts\Libraries\jquery.validate.min.js" />
@@ -176,7 +178,7 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>56830</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
@@ -191,10 +193,24 @@
<UserProperties package_1json__JSONSchema="http://json.schemastore.org/resjson" />
</VisualStudio>
</ProjectExtensions>
<PropertyGroup>
<PreBuildEvent>if $(ConfigurationName) == Release (
cd $(ProjectDir)
npm install
gulp minifyFilesForRelease
)
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
<Target Name="AfterBuild">
<ItemGroup>
<Content Include="dist\*.*" />
</ItemGroup>
</Target>
</Project>
@@ -4,9 +4,10 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<!-- build:css /dist/site.css -->
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/Site.css" rel="stylesheet" />
<link href="/Content/bootstrap.css" rel="stylesheet" />
<link href="/Content/Site.css" rel="stylesheet" />
<!-- endbuild -->
</head>
@@ -38,9 +39,9 @@
</footer>
</div>
<!-- build:js /dist/libs.js -->
<script src="~/Scripts/Libraries/jquery.js"></script>
<script src="~/Scripts/Libraries/bootstrap.js"></script>
<script src="~/Scripts/Libraries/respond.js"></script>
<script src="/Scripts/Libraries/jquery.js"></script>
<script src="/Scripts/Libraries/bootstrap.js"></script>
<script src="/Scripts/Libraries/respond.js"></script>
<!-- endbuild -->
@RenderSection("scripts", required: false)
</body>
@@ -12,6 +12,41 @@ gulp.task('sass', function () {
;
});
gulp.task('minifyFilesForRelease', function () {
var cssFilter = plugins.filter('**/*.css', { restore: true });
var jsFilter = plugins.filter('**/*.js', { restore: true });
var assets = plugins.useref.assets();
gulp.src('./**/*.cshtml')
.pipe(assets)
//Process JavaScript
.pipe(jsFilter)
.pipe(plugins.uglify())
.pipe(plugins.rev())
.pipe(assets.restore())
.pipe(jsFilter.restore)
//Process CSS
.pipe(cssFilter)
.pipe(plugins.minifyCss({
keepSpecialComments: 0
}))
.pipe(plugins.rev())
.pipe(assets.restore())
.pipe(cssFilter.restore)
.pipe(plugins.useref())
.pipe(plugins.revReplace({
replaceInExtensions: ['.js', '.css', '.html', '.cshtml']
}))
.pipe(gulp.dest(function (data) {
return data.base;
}
));
});
gulp.task('watch-sass', function () {
plugins.livereload.listen();
gulp.watch('./Content/*.scss', ['sass']);
@@ -7,6 +7,13 @@
"gulp-sass": "~2.0.4",
"gulp-sourcemaps": "~1.5.2",
"gulp-autoprefixer": "~2.3.1",
"gulp-livereload": "~3.8.0"
"gulp-livereload": "~3.8.0",
"gulp-useref": "~1.3.0",
"gulp-uglify": "~1.2.0",
"gulp-minify-css": "~1.2.1",
"gulp-rev": "~5.1.0",
"gulp-rev-replace": "~0.4.2",
"gulp-filter": "~3.0.0"
}
}

0 comments on commit a2a5eb8

Please sign in to comment.