Feature/#35 build tools #36
28
gulpfile.js
28
gulpfile.js
|
@ -3,6 +3,10 @@ const cssnano = require('cssnano')
|
||||||
Serraniel
commented
Review
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
const gulpLoadPlugins = require('gulp-load-plugins')
|
const gulpLoadPlugins = require('gulp-load-plugins')
|
||||||
const uglify = require('gulp-uglify-es').default;
|
const uglify = require('gulp-uglify-es').default;
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
|
const browserify = require('browserify');
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
const babelify = require('babelify');
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
const source = require('vinyl-source-stream');
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
const buffer = require('vinyl-buffer');
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
|
||||||
const $ = gulpLoadPlugins()
|
const $ = gulpLoadPlugins()
|
||||||
|
|
||||||
|
@ -29,7 +33,6 @@ const tmp = {
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
scripts: '.tmp/javascript',
|
scripts: '.tmp/javascript',
|
||||||
images: '.tmp/images',
|
images: '.tmp/images',
|
||||||
vendor: '.tmp/libs',
|
vendor: '.tmp/libs',
|
||||||
maps: '../sourcemaps',
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dist path
|
// Dist path
|
||||||
|
@ -40,7 +43,6 @@ const dist = {
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
scripts: 'dist/javascript',
|
scripts: 'dist/javascript',
|
||||||
images: 'dist/images',
|
images: 'dist/images',
|
||||||
vendor: 'dist/libs',
|
vendor: 'dist/libs',
|
||||||
maps: 'dist/sourcemaps',
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build mode
|
// Build mode
|
||||||
|
@ -86,21 +88,27 @@ gulp.task('styles', () => {
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
showFiles: true
|
showFiles: true
|
||||||
}))
|
}))
|
||||||
// write sourcemaps
|
// write sourcemaps
|
||||||
.pipe($.if(isDev, $.sourcemaps.write(tmp.maps)))
|
.pipe($.if(isDev, $.sourcemaps.write()))
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
.pipe(gulp.dest(tmp.styles))
|
.pipe(gulp.dest(tmp.styles))
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('scripts', () => {
|
gulp.task('scripts', () => {
|
||||||
return gulp.src(`${src.scripts}/**/*.js`)
|
let b = browserify({
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
|
entries: `${src.scripts}/index.js`,
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
debug: true
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
});
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
return b.transform('babelify').bundle()
|
||||||
```suggestion
debug: isDev
```
|
|||||||
.pipe($.plumber())
|
.pipe($.plumber())
|
||||||
.pipe($.if(isDev, $.sourcemaps.init()))
|
.pipe(source('app.js'))
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
.pipe($.babel())
|
.pipe(buffer())
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
|
.pipe($.if(isDev, $.sourcemaps.init({ loadMaps: true })))
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
//.pipe(uglify({ compress: { drop_console: isProd, drop_debugger: isProd } }))
|
||||||
```suggestion
debug: isDev
```
|
|||||||
.pipe($.rename({ suffix: '.min' }))
|
.pipe($.rename({ suffix: '.min' }))
|
||||||
.pipe($.if('*.js', uglify({ compress: { drop_console: isProd, drop_debugger: isProd } })))
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
.pipe($.size({
|
.pipe($.size({
|
||||||
showFiles: true,
|
showFiles: true,
|
||||||
}))
|
}))
|
||||||
.pipe($.if(isDev, $.sourcemaps.write(tmp.maps)))
|
.pipe($.if(isDev, $.sourcemaps.write()))
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
.pipe(gulp.dest(`${tmp.scripts}`))
|
.pipe(gulp.dest(`${tmp.scripts}`))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -165,10 +173,6 @@ gulp.task('dist:copy', (done) => {
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
|||||||
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
||||||
.pipe(gulp.dest(dist.styles))
|
.pipe(gulp.dest(dist.styles))
|
||||||
|
|
||||||
// sourcemaps
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
gulp.src(`${tmp.root}/**/*.map`)
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
.pipe(gulp.dest(dist.root))
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
|
|
||||||
```suggestion
debug: isDev
```
|
|||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
Loading…
Reference in a new issue