-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add browserify and dependencies to script bundle
- Loading branch information
Showing
14 changed files
with
296 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import del from 'del'; | ||
|
||
export function cleanTask() { | ||
return del(['dist']); | ||
return function(cb: (error?: Error | null) => void) { | ||
del(['dist']).then(() => cb()).catch(cb); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { dest, src } from 'gulp'; | ||
import { dest, src, TaskFunction } from 'gulp'; | ||
import imagemin from 'gulp-imagemin'; | ||
|
||
export function imagesTask() { | ||
return src('src/img/**/*') | ||
.pipe(imagemin()) | ||
.pipe(dest('dist/img')); | ||
export function imagesTask(): TaskFunction { | ||
return function() { | ||
return src('src/img/**/*') | ||
.pipe(imagemin()) | ||
.pipe(dest('dist/img')); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
import { dest, src } from 'gulp'; | ||
import babel from 'gulp-babel'; | ||
import plumber from 'gulp-plumber'; | ||
import browserify from 'browserify'; | ||
import { dest, TaskFunction } from 'gulp'; | ||
import rename from 'gulp-rename'; | ||
import sourcemaps from 'gulp-sourcemaps'; | ||
import terser from 'gulp-terser'; | ||
import typescript from 'gulp-typescript'; | ||
import uglify from 'gulp-uglify'; | ||
import tsify from 'tsify'; | ||
import buffer from 'vinyl-buffer'; | ||
import source from 'vinyl-source-stream'; | ||
import { UserChoices } from '../types'; | ||
|
||
export function scriptTask(choices: UserChoices) { | ||
return function () { | ||
return src(`src/${choices.script.toLowerCase()}/**/*.${choices.script === 'TypeScript' ? 'ts' : 'js'}`, { sourcemaps: true }) | ||
.pipe(plumber()) | ||
.pipe(choices.script === 'TypeScript' ? typescript() : babel({ presets: ['@babel/preset-env'] })) | ||
.pipe(terser()) | ||
.pipe(sourcemaps.write('.')) | ||
export function scriptTask(choices: UserChoices): TaskFunction { | ||
return function() { | ||
const b = browserify({ | ||
entries: `src/${choices.script === 'TypeScript' ? 'ts' : 'js'}/main.${choices.script === 'TypeScript' ? 'ts' : 'js'}`, | ||
debug: true, | ||
}); | ||
|
||
if (choices.script === 'TypeScript') { | ||
b.plugin(tsify); | ||
} | ||
|
||
return b.bundle() | ||
.pipe(source('main.js')) | ||
.pipe(buffer()) | ||
.pipe(sourcemaps.init({ loadMaps: true })) | ||
.pipe(dest('dist/js')) | ||
.pipe(uglify()) | ||
.pipe(rename('main.min.js')) | ||
.pipe(sourcemaps.write('./')) | ||
.pipe(dest('dist/js')); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"script": "JavaScript", | ||
"script": "TypeScript", | ||
"style": "Sass", | ||
"markup": "Pug", | ||
"addNormalize": true, | ||
|
Oops, something went wrong.