Skip to content

Commit

Permalink
gulp: Run optimization only in production mode (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Jan 31, 2017
1 parent 0374dba commit a8cb23d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions gulpfile.js
@@ -1,17 +1,22 @@
const path = require('path');

const Builder = require('gulp-bem-bundle-builder');
const bundler = require('gulp-bem-bundler-fs');
const gulp = require('gulp');
const path = require('path');
const postcss = require('gulp-postcss');
const debug = require('gulp-debug');
const csso = require('gulp-csso');
const filter = require('through2-filter').obj;
const merge = require('merge2');
const concat = require('gulp-concat');
const gulpif = require('gulp-if');
const uglify = require('gulp-uglify');
const bemhtml = require('gulp-bem-xjst').bemhtml;
const toHtml = require('gulp-bem-xjst').toHtml;

const YENV = process.env.YENV || 'development';
const isProd = YENV === 'production';

const builder = Builder({
levels: [
'node_modules/bem-core/common.blocks',
Expand Down Expand Up @@ -55,16 +60,16 @@ gulp.task('build', () => {
require('postcss-reporter')()
]))
.pipe(concat(bundle.name + '.min.css'))
.pipe(csso()),
.pipe(gulpif(isProd, csso())),
js: bundle =>
merge(
gulp.src(require.resolve('ym')),
bundle.src('js').pipe(filter(f => ~['vanilla.js', 'browser.js', 'js'].indexOf(f.tech))),
bundle.src('js').pipe(filter(file => file.tech === 'bemhtml.js'))
.pipe(concat('browser.bemhtml.js')).pipe(bemhtml())
.pipe(concat('browser.bemhtml.js')).pipe(bemhtml({ elemJsInstances: true }))
)
.pipe(uglify())
.pipe(concat(bundle.name + '.min.js')),
.pipe(concat(bundle.name + '.min.js'))
.pipe(gulpif(isProd, uglify())),
tmpls: bundle =>
bundle.src('bemhtml')
.pipe(concat('any.bemhtml.js'))
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"gulp-concat": "^2.6.0",
"gulp-csso": "^2.0.0",
"gulp-debug": "^3.0.0",
"gulp-if": "^2.0.2",
"gulp-one-of": "^1.0.0",
"gulp-postcss": "^6.2.0",
"gulp-uglify": "^2.0.0",
Expand Down

0 comments on commit a8cb23d

Please sign in to comment.