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 uglify = require('gulp-uglify-es').default;
|
||||
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()
|
||||
|
||||
|
@ -29,7 +33,6 @@ const tmp = {
|
|||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
||||
scripts: '.tmp/javascript',
|
||||
images: '.tmp/images',
|
||||
vendor: '.tmp/libs',
|
||||
maps: '../sourcemaps',
|
||||
```suggestion
debug: isDev
```
|
||||
}
|
||||
|
||||
// Dist path
|
||||
|
@ -40,7 +43,6 @@ const dist = {
|
|||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
||||
scripts: 'dist/javascript',
|
||||
images: 'dist/images',
|
||||
vendor: 'dist/libs',
|
||||
maps: 'dist/sourcemaps',
|
||||
```suggestion
debug: isDev
```
|
||||
}
|
||||
|
||||
// Build mode
|
||||
|
@ -86,21 +88,27 @@ gulp.task('styles', () => {
|
|||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
||||
showFiles: true
|
||||
}))
|
||||
// write sourcemaps
|
||||
.pipe($.if(isDev, $.sourcemaps.write(tmp.maps)))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe($.if(isDev, $.sourcemaps.write()))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe(gulp.dest(tmp.styles))
|
||||
})
|
||||
|
||||
gulp.task('scripts', () => {
|
||||
return gulp.src(`${src.scripts}/**/*.js`)
|
||||
```suggestion
debug: isDev
```
|
||||
let b = browserify({
|
||||
```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($.if(isDev, $.sourcemaps.init()))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe($.babel())
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe(source('app.js'))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe(buffer())
|
||||
```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($.if('*.js', uglify({ compress: { drop_console: isProd, drop_debugger: isProd } })))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe($.size({
|
||||
showFiles: true,
|
||||
}))
|
||||
.pipe($.if(isDev, $.sourcemaps.write(tmp.maps)))
|
||||
```suggestion
debug: isDev
```
|
||||
.pipe($.if(isDev, $.sourcemaps.write()))
|
||||
```suggestion
debug: isDev
```
|
||||
.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}`)
|
||||
.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();
|
||||
})
|
||||
|
||||
|
|
|||
```suggestion
debug: isDev
```
```suggestion
debug: isDev
```
|
Loading…
Reference in a new issue