From d99f7cf4da0f77869897c89ff897638da507bc63 Mon Sep 17 00:00:00 2001 From: Andrey Shchekin Date: Sat, 23 Apr 2016 22:29:19 +1200 Subject: [PATCH] Enabled minification by default. --- source/Web/browserslist | 1 + source/Web/gulpfile.js | 10 +++++----- source/Web/package.json | 4 ++++ source/Web/webpack.config.js | 10 +++------- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 source/Web/browserslist diff --git a/source/Web/browserslist b/source/Web/browserslist new file mode 100644 index 0000000..aaea285 --- /dev/null +++ b/source/Web/browserslist @@ -0,0 +1 @@ +Last 2 versions \ No newline at end of file diff --git a/source/Web/gulpfile.js b/source/Web/gulpfile.js index f9b5d48..ad07dde 100644 --- a/source/Web/gulpfile.js +++ b/source/Web/gulpfile.js @@ -2,19 +2,19 @@ 'use strict'; var gulp = require('gulp'); -var plumber = require('gulp-plumber'); -var uglify = require('gulp-uglify'); var g = require('gulp-load-plugins')(); -var htmlreplace = require('gulp-html-replace'); var webpack = require('webpack-stream'); var assign = require('object-assign'); gulp.task('less', function () { return gulp .src('./less/app.less') + // this doesn't really work properly, e.g. https://github.com/ai/autoprefixer-core/issues/27 .pipe(g.sourcemaps.init()) .pipe(g.less()) - .pipe(g.autoprefixer({ browsers: ['last 2 versions'], cascade: false })) + .pipe(g.autoprefixer({ cascade: false })) + .pipe(g.cleanCss({ processImport: false })) + .pipe(g.rename('app.min.css')) .pipe(g.sourcemaps.write('.')) .pipe(gulp.dest('wwwroot')); }); @@ -31,7 +31,7 @@ gulp.task('js', function () { gulp.task('html', function () { return gulp .src('./index.html') - .pipe(htmlreplace({ js: 'app.min.js', css: 'app.css' })) + .pipe(g.htmlReplace({ js: 'app.min.js', css: 'app.min.css' })) .pipe(gulp.dest('wwwroot')); }); diff --git a/source/Web/package.json b/source/Web/package.json index de1e4a4..ba3eec1 100644 --- a/source/Web/package.json +++ b/source/Web/package.json @@ -8,13 +8,17 @@ "babel-preset-es2015": "^6.3.13", "gulp": "^3.9.0", "gulp-autoprefixer": "^3.1.0", + "gulp-clean-css": "^2.0.6", "gulp-concat": "^2.6.0", "gulp-html-replace": "^1.5.5", "gulp-less": "^3.0.5", "gulp-load-plugins": "^1.2.2", "gulp-plumber": "^0.6.6", + "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^1.5.1", + "less-plugin-autoprefix": "^1.5.1", + "less-plugin-clean-css": "^1.5.1", "object-assign": "^4.0.1", "webpack-stream": "^3.1.0" }, diff --git a/source/Web/webpack.config.js b/source/Web/webpack.config.js index a8ff356..9c7a777 100644 --- a/source/Web/webpack.config.js +++ b/source/Web/webpack.config.js @@ -1,17 +1,13 @@ /* globals module:false, require:false, process:false */ var webpack = require('webpack'); - -var plugins = []; -if (process.env.NODE_ENV === 'production') { - plugins.push(new webpack.optimize.UglifyJsPlugin()); -} - module.exports = { externals: { jquery: 'jQuery' }, devtool: 'source-map', - plugins: plugins, + plugins: [ + new webpack.optimize.UglifyJsPlugin() + ], entry: [ 'regenerator/runtime', './js/app.js'