1.0.2 • Published 6 years ago
@wok-cli/plugin-useref v1.0.2
gulp-useref for Wok
This plugin implements gulp-useref.
| Hook types | Production only | Purpose |
|---|---|---|
| lazypipe | yes | assets optimization |
Installation
This plugin requires @wok-cli/core.
npm i @wok-cli/core @wok-cli/plugin-useref --save-devParameters
Configuration path: useref.
| parameter | type | default | note |
|---|---|---|---|
sourcemaps | booleanstring | write sourcemaps(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>