Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrodriguez committed Dec 12, 2017
2 parents 5dd9605 + 08f085f commit 358403d
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 47 deletions.
154 changes: 108 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,30 +113,36 @@ This is the default `.hugulprc`:

```json
{
version: 1,
pipeline: ["images", "styles", "scripts", "fingerprint", "html"],
path: {
styles: "styles",
images: "images",
scripts: "scripts"
"version": 2,
"pipeline": ["images", "styles", "scripts", "fingerprint", "html"],
"path": {
"styles": "styles",
"images": "images",
"scripts": "scripts"
},
watch: {
source: "assets",
target: "static"
"watch": {
"source": "assets",
"target": "static"
},
build: {
source: "public",
target: "public"
"build": {
"source": "public",
"target": "public"
},
autoprefixer: {
browsers: ["last 2 versions"]
"autoprefixer": {
"browsers": ["last 2 versions"]
},
cleancss: {
advanced: false
"cleancss": {
"advanced": false
},
htmlmin: {
collapsedWhitespace: true,
removeEmptyElements: true
"htmlmin": {
"collapsedWhitespace": true,
"removeEmptyElements": true
},
"gifsicle": { "interlaced": true },
"jpegtran": { "progressive": true },
"optipng": { "optimizationLevel": 5 },
"svgo": {
"plugins": [{ "removeViewBox": true }, { "cleanupIDs": false }]
}
}
```
Expand Down Expand Up @@ -192,7 +198,7 @@ Type: array <br>
Default:

```json
pipeline: ['images', 'styles', 'scripts', 'fingerprint', 'html']
"pipeline": ["images", "styles", "scripts", "fingerprint", "html"]
```

| Task | Description |
Expand All @@ -206,7 +212,7 @@ pipeline: ['images', 'styles', 'scripts', 'fingerprint', 'html']
Let's say you don't want to fingerprint the assets. Just set _pipeline_ to

```json
pipeline: ['images', 'styles', 'scripts', 'html']
"pipeline": ["images", "styles", "scripts", "html"]
```

By removing the _fingerprint_ task, it will not be executed.
Expand All @@ -221,20 +227,20 @@ Type: object <br>
Default:

```json
path: {
styles: 'styles',
images: 'images',
scripts: 'scripts'
"path": {
"styles": "styles",
"images": "images",
"scripts": "scripts"
}
```

So if you prefer your styles folder to be called css, and scripts to be called js, you would change it to:

```json
path: {
styles: 'css',
images: 'images',
scripts: 'js'
"path": {
"styles": "css",
"images": "images",
"scripts": "js"
}
```

Expand All @@ -246,9 +252,9 @@ Type: object <br>
Default:

```json
watch: {
source: 'assets',
target: 'static'
"watch": {
"source": "assets",
"target": "static"
}
```

Expand All @@ -261,9 +267,9 @@ If you customized `path` as per above, it will watch `assets/css` and `assets/js
If you additionally want the `assets` folder to be called `resources`, change _source_ to `resources`

```json
watch: {
source: 'resources',
target: 'static'
"watch": {
"source": "resources",
"target": "static"
}
```

Expand All @@ -281,9 +287,9 @@ Type: object <br>
Default:

```json
build: {
source: 'public',
target: 'public'
"build": {
"source": "public",
"target": "public"
}
```

Expand All @@ -301,8 +307,8 @@ Type: object<br>
Default:

```json
autoprefixer: {
browsers: ['last 2 versions']
"autoprefixer": {
"browsers": ["last 2 versions"]
}
```

Expand All @@ -315,8 +321,8 @@ Task: `styles`
Default:

```json
cleancss: {
advanced: false
"cleancss": {
"advanced": false
}
```

Expand All @@ -329,9 +335,65 @@ Task: `html`
Default:

```json
htmlmin: {
collapsedWhitespace: true,
removeEmptyElements: true
"htmlmin": {
"collapsedWhitespace": true,
"removeEmptyElements": true
}
```

### gifsicle

Options for `gifsicle`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.

Task: `images`

Default:

```json
"gifsicle": {
"interlaced": true
}
```

### jpegtran

Options for `gifsicle`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.

Task: `images`

Default:

```json
"jpegtran": {
"progressive": true
}
```

### optipng

Options for `gifsicle`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.

Task: `images`

Default:

```json
"optipng": {
"optimizationLevel": 5
}
```

### svgo

Options for `gifsicle`. Check [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) for documentation.

Task: `images`

Default:

```json
"svgo": {
"plugins": [{ "removeViewBox": true }, { "cleanupIDs": false }]
}
```

Expand All @@ -340,7 +402,7 @@ htmlmin: {
Whenever a new `hugulp` version becomes available, you can update it by running

```bash
$ npm update -g hugulp
$ npm install -g hugulp
```

## PR
Expand Down
9 changes: 8 additions & 1 deletion gulp/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ gulp.task('build', function(cb) {
gulp.task('images', function() {
return gulp
.src(path.join(config.build.source, config.path.images, '**', '*.*')) // i.e.: public/images/**/*.*
.pipe(imagemin())
.pipe(
imagemin([
imagemin.gifsicle(config.gifsicle),
imagemin.jpegtran(config.jpegtran),
imagemin.optipng(config.optipng),
imagemin.svgo(config.svgo)
])
)
.pipe(gulp.dest(path.join(config.build.target, config.path.images))) // i.e.: public/images
})

Expand Down
6 changes: 6 additions & 0 deletions gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ gulp.task('watch', function() {
path.join(config.watch.source, config.path.styles, '**', '*.css')
]

gutil.log(gutil.colors.green(`running styles task ...`))
gulp.start('styles')

gutil.log(gutil.colors.green(`watching ${JSON.stringify(styles)}`))

watch(styles, {}, function handle(param) {
Expand All @@ -44,6 +47,9 @@ gulp.task('watch', function() {
path.join(config.watch.source, config.path.scripts, '**', '*.js')
]

gutil.log(gutil.colors.green(`running scripts task ...`))
gulp.start('scripts')

gutil.log(gutil.colors.green(`watching ${JSON.stringify(scripts)}`))

watch(scripts, {}, function handle(param) {
Expand Down

0 comments on commit 358403d

Please sign in to comment.