1.0.2 • Published 4 years ago

@wok-cli/plugin-useref v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

gulp-useref for Wok

This plugin implements gulp-useref.

Hook typesProduction onlyPurpose
lazypipeyesassets optimization

Installation

This plugin requires @wok-cli/core.

npm i @wok-cli/core @wok-cli/plugin-useref --save-dev

Parameters

Configuration path: useref.

parametertypedefaultnote
sourcemapsbooleanstringwrite sourcemaps(1)
  1. Defaults to the value of env.sourcemaps.

All other parameters will be used as gulp-useref configuration options.

Note that the searchPath and base options are enhanced with support for environment templates.

Usage

The most common usage scenario of this plugin is with @wok-cli/task-views:

const $ = require('@wok-cli/core');
const views = require('@wok-cli/task-views');
const useref = require('@wok-cli/plugin-useref');

const viewsTask = $.task(views, {
  src: ['src/**/*.html'],
  dest: 'public',
});

viewsTask.tap('post', 'useref', useref);

exports.views = viewsTask;

Refer to gulp-useref documentation for usage details.

Custom Blocks

gulp-useref allows you to do custom processing via custom blocks.

This plugin implements by default a custom replace block, which can be used to replace a script tag src attribute without processing the source file.

Example input:

<!-- build:replace /vendors/modernizr.min.js defer -->
<script src="/vendors/modernizr.js" defer></script>
<!-- endbuild -->

Output with --production:

<script src="/vendors/modernizr.min.js" defer></script>