From fdfa33036eeddafcb6de6c0f31c126a6ee0d272c Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Tue, 7 Jun 2016 20:56:03 +0200 Subject: [PATCH 1/5] Introduce Bundler to web basic (StarterWeb) template This commit brings changes from aspnet/Templates#592 to starter web project template. The Gulp, Grunt options are removed with NPM support removal. Thanks! --- app/index.js | 8 +-- templates/projects/webbasic/Gruntfile.js | 10 ---- templates/projects/webbasic/bundleconfig.json | 20 +++++++ templates/projects/webbasic/gulpfile.js | 45 ---------------- templates/projects/webbasic/package.json | 13 ----- templates/projects/webbasic/project.json | 9 +++- test/test-core.js | 52 +------------------ 7 files changed, 30 insertions(+), 127 deletions(-) delete mode 100644 templates/projects/webbasic/Gruntfile.js create mode 100644 templates/projects/webbasic/bundleconfig.json delete mode 100755 templates/projects/webbasic/gulpfile.js delete mode 100755 templates/projects/webbasic/package.json diff --git a/app/index.js b/app/index.js index 141d6e03..2c4a4348 100644 --- a/app/index.js +++ b/app/index.js @@ -258,19 +258,13 @@ var AspnetGenerator = yeoman.generators.Base.extend({ break; case 'webbasic': this.sourceRoot(path.join(__dirname, '../templates/projects/' + this.type)); - // Grunt or Gulp - if (this.options.grunt) { - this.fs.copyTpl(this.templatePath('Gruntfile.js'), this.applicationName + '/Gruntfile.js', this.templatedata); - } else { - this.fs.copyTpl(this.templatePath('gulpfile.js'), this.applicationName + '/gulpfile.js', this.templatedata); - } // individual files (configs, etc) this.fs.copyTpl(this.sourceRoot() + '/../../Dockerfile.txt', this.applicationName + '/Dockerfile', this.templatedata); this.fs.copy(this.templatePath('.bowerrc'), this.applicationName + '/.bowerrc'); + this.fs.copy(this.templatePath('bundleconfig.json'), this.applicationName + '/bundleconfig.json'); this.fs.copy(this.sourceRoot() + '/../../gitignore.txt', this.applicationName + '/.gitignore'); this.fs.copyTpl(this.templatePath('bower.json'), this.applicationName + '/bower.json', this.templatedata); this.fs.copyTpl(this.templatePath('appsettings.json'), this.applicationName + '/appsettings.json', this.templatedata); - this.fs.copyTpl(this.templatePath('package.json'), this.applicationName + '/package.json', this.templatedata); this.fs.copyTpl(this.templatePath('project.json'), this.applicationName + '/project.json', this.templatedata); this.fs.copyTpl(this.templatePath('Program.cs'), this.applicationName + '/Program.cs', this.templatedata); // Properties diff --git a/templates/projects/webbasic/Gruntfile.js b/templates/projects/webbasic/Gruntfile.js deleted file mode 100644 index 27b3117e..00000000 --- a/templates/projects/webbasic/Gruntfile.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - This file is the main entry point for defining grunt tasks and using grunt plugins. - Click here to learn more: https://docs.asp.net/en/latest/client-side/using-grunt.html -*/ -"use strict"; - -module.exports = function(grunt) { - grunt.initConfig({ - }); -}; diff --git a/templates/projects/webbasic/bundleconfig.json b/templates/projects/webbasic/bundleconfig.json new file mode 100644 index 00000000..8fb36036 --- /dev/null +++ b/templates/projects/webbasic/bundleconfig.json @@ -0,0 +1,20 @@ +[ + { + "outputFileName": "wwwroot/css/site.css", + "inputFiles": [ + "wwwroot/css/site.css" + ], + "minify": { + "enabled": true + } + }, + { + "outputFileName": "wwwroot/js/site.js", + "inputFiles": [ + "wwwroot/js/site.js" + ], + "minify": { + "enabled": true + } + } +] diff --git a/templates/projects/webbasic/gulpfile.js b/templates/projects/webbasic/gulpfile.js deleted file mode 100755 index 55871e61..00000000 --- a/templates/projects/webbasic/gulpfile.js +++ /dev/null @@ -1,45 +0,0 @@ -/// -"use strict"; - -var gulp = require("gulp"), - rimraf = require("rimraf"), - concat = require("gulp-concat"), - cssmin = require("gulp-cssmin"), - uglify = require("gulp-uglify"); - -var webroot = "./wwwroot/"; - -var paths = { - js: webroot + "js/**/*.js", - minJs: webroot + "js/**/*.min.js", - css: webroot + "css/**/*.css", - minCss: webroot + "css/**/*.min.css", - concatJsDest: webroot + "js/site.min.js", - concatCssDest: webroot + "css/site.min.css" -}; - -gulp.task("clean:js", function (cb) { - rimraf(paths.concatJsDest, cb); -}); - -gulp.task("clean:css", function (cb) { - rimraf(paths.concatCssDest, cb); -}); - -gulp.task("clean", ["clean:js", "clean:css"]); - -gulp.task("min:js", function () { - return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) - .pipe(concat(paths.concatJsDest)) - .pipe(uglify()) - .pipe(gulp.dest(".")); -}); - -gulp.task("min:css", function () { - return gulp.src([paths.css, "!" + paths.minCss]) - .pipe(concat(paths.concatCssDest)) - .pipe(cssmin()) - .pipe(gulp.dest(".")); -}); - -gulp.task("min", ["min:js", "min:css"]); diff --git a/templates/projects/webbasic/package.json b/templates/projects/webbasic/package.json deleted file mode 100755 index 16a66434..00000000 --- a/templates/projects/webbasic/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "<%= namespace.toLowerCase() %>", - "version": "0.0.0", - "private": true, - "devDependencies": {<% if(!grunt){ %> - "gulp": "3.9.1", - "gulp-concat": "2.6.0", - "gulp-cssmin": "0.1.7", - "gulp-uglify": "1.5.3", - "rimraf": "2.5.2"<% } %><% if(grunt){ %> - "grunt": "1.0.1"<% } %> - } -} diff --git a/templates/projects/webbasic/project.json b/templates/projects/webbasic/project.json index 0ab37150..3f2fa326 100755 --- a/templates/projects/webbasic/project.json +++ b/templates/projects/webbasic/project.json @@ -22,6 +22,13 @@ }, "tools": { + "BundlerMinifier.Core": { + "version": "2.0.200", + "imports": [ + "portable-net45+win8+dnxcore50", + "portable-net40+sl5+win8+wp8+wpa81" + ] + }, "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8+dnxcore50" @@ -68,7 +75,7 @@ }, "scripts": { - "prepublish": [ "npm install", "bower install"<% if(!grunt){ %>, "gulp clean", "gulp min"<% } %> ], + "prepublish": [ "bower install" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }, diff --git a/test/test-core.js b/test/test-core.js index b945541a..f1c305cb 100644 --- a/test/test-core.js +++ b/test/test-core.js @@ -555,53 +555,6 @@ describe('aspnet - Web Application (Semantic UI)', function() { }); - -/* - * yo aspnet Web Application Basic - Grunt option - */ -describe('aspnet - Web Application Basic w/grunt', function() { - - util.goCreateApplicationWithOptions('webbasic', 'gruntTest', 'bootstrap', { - grunt: 'grunt' - }); - - describe('Checking directories', function() { - it('Application directory created', function() { - assert.file('gruntTest/'); - }); - - it('grunt file created', function() { - assert.file('gruntTest/Gruntfile.js'); - }); - - it('gulpfile does NOT exist', function() { - assert.noFile('gruntTest/gulpfile.js'); - }); - }); -}); - -/* - * yo aspnet Web Application Basic - No Grunt option - */ -describe('aspnet - Web Application Basic w/o grunt', function() { - - util.goCreateApplication('webbasic', 'gulpTest'); - - describe('Checking directories', function() { - it('Application directory created', function() { - assert.file('gulpTest/'); - }); - - it('gulp file created', function() { - assert.file('gulpTest/gulpfile.js'); - }); - - it('grunt file does NOT exist', function() { - assert.noFile('gulpTest/Gruntfile.js'); - }); - }); -}); - /* * yo aspnet Web Application (Bootstrap) */ @@ -658,10 +611,9 @@ describe('aspnet - Web Application Basic (Bootstrap)', function() { 'webTest/.bowerrc', 'webTest/.gitignore', 'webTest/bower.json', + 'webTest/bundleconfig.json', 'webTest/appsettings.json', 'webTest/Controllers/HomeController.cs', - 'webTest/gulpfile.js', - 'webTest/package.json', 'webTest/Program.cs', 'webTest/project.json', 'webTest/Properties/launchSettings.json', @@ -759,8 +711,6 @@ describe('aspnet - Web Application Basic (Semantic UI)', function() { 'webTest/bower.json', 'webTest/appsettings.json', 'webTest/Controllers/HomeController.cs', - 'webTest/gulpfile.js', - 'webTest/package.json', 'webTest/Program.cs', 'webTest/project.json', 'webTest/Properties/launchSettings.json', From d6cd67e236f05e6bf5b72ef5735bdb3db3628178 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 9 Jun 2016 20:56:35 +0200 Subject: [PATCH 2/5] :arrow_up: Update Bundler version The 2.0.208 fixes *nix paths problem --- templates/projects/webbasic/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/projects/webbasic/project.json b/templates/projects/webbasic/project.json index 3f2fa326..a651d37e 100755 --- a/templates/projects/webbasic/project.json +++ b/templates/projects/webbasic/project.json @@ -23,7 +23,7 @@ "tools": { "BundlerMinifier.Core": { - "version": "2.0.200", + "version": "2.0.208", "imports": [ "portable-net45+win8+dnxcore50", "portable-net40+sl5+win8+wp8+wpa81" From b5b728d8960bebf82b04e4fec43543314ca51348 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 9 Jun 2016 21:24:29 +0200 Subject: [PATCH 3/5] Add missing Bundle to Semantic UI overrides --- .../semantic/webbasic/bundleconfig.json | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 templates/overrides/semantic/webbasic/bundleconfig.json diff --git a/templates/overrides/semantic/webbasic/bundleconfig.json b/templates/overrides/semantic/webbasic/bundleconfig.json new file mode 100644 index 00000000..5ae75176 --- /dev/null +++ b/templates/overrides/semantic/webbasic/bundleconfig.json @@ -0,0 +1,29 @@ +[ + { + "outputFileName": "wwwroot/css/site.min.css", + "inputFiles": [ + "wwwroot/css/site.css" + ], + "minify": { + "enabled": true + } + }, + { + "outputFileName": "wwwroot/js/site.min.js", + "inputFiles": [ + "wwwroot/js/site.js" + ], + "minify": { + "enabled": true + } + }, + { + "outputFileName": "wwwroot/js/semantic.validation.min.js", + "inputFiles": [ + "wwwroot/js/semantic.validation.js" + ], + "minify": { + "enabled": true + } + } +] From 139ba2ff0f0f870d906e42ab55269d5461963675 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 9 Jun 2016 21:25:38 +0200 Subject: [PATCH 4/5] Set post-install of NPM to false --- app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/index.js b/app/index.js index 2c4a4348..2c66ef7f 100644 --- a/app/index.js +++ b/app/index.js @@ -337,7 +337,7 @@ var AspnetGenerator = yeoman.generators.Base.extend({ if(!this.options['skip-install'] && (this.type === 'web' || this.type === 'webbasic')) { process.chdir(this.applicationName); this.installDependencies({ - npm: true, + npm: false, bower: true, callback: this._showUsageHints.bind(this) }); From 707a8caf23bc6d30d6b1aeee37d0a48b75abefa7 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Thu, 9 Jun 2016 21:28:16 +0200 Subject: [PATCH 5/5] Fix output path names --- templates/projects/webbasic/bundleconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/projects/webbasic/bundleconfig.json b/templates/projects/webbasic/bundleconfig.json index 8fb36036..6eadf24e 100644 --- a/templates/projects/webbasic/bundleconfig.json +++ b/templates/projects/webbasic/bundleconfig.json @@ -1,6 +1,6 @@ [ { - "outputFileName": "wwwroot/css/site.css", + "outputFileName": "wwwroot/css/site.min.css", "inputFiles": [ "wwwroot/css/site.css" ], @@ -9,7 +9,7 @@ } }, { - "outputFileName": "wwwroot/js/site.js", + "outputFileName": "wwwroot/js/site.min.js", "inputFiles": [ "wwwroot/js/site.js" ],