grunt-dolphin-optimizer

2019-10-13

grunt-dolphin-optimizer是什么

什么是grunt-dolphin-optimizer,Optimize tvs files utilizing "uglify-js", "clean-css" and "html-minifier", resolve all the resource paths referred by the files and output files ready to deploy

grunt-dolphin-optimizer使用教程帮助文档

grunt-dolphin-optimizer

Optimize tvs files utilizing "uglify-js", "clean-css" and "html-minifier", resolve all the resource paths referred by the files and output files ready to deploy

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Gruntbefore, be sure to check out the Getting Startedguide, as it explains how to create a Gruntfileas well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-dolphin-optimizer --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-dolphin-optimizer');

The "dolphin-optimizer" task

Overview

In your project's Gruntfile, add a section named dolphin-optimizerto the data object passed into grunt.initConfig().

grunt.initConfig({
  dolphin-optimizer: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.srcPath

Type: StringDefault value: src

A string value that is used to designate src directory path.

options.buildPath

Type: StringDefault value: build

A string value that is used to designate output directory path.

options.embeded

Type: String|BooleanDefault value: css

'css' stands for only embed stylesheets; 'js' stands for only embed js code; true stands for embed both js code and stylesheets; false do not embed either; this setting is overwritten by the inline data-how="xxx" attribute.

options.optimizeOptions

Type: ObjectDefault value: { js: true, css: true, html:{ removeComments: true } }

Set 'uglify-js','clean-css' and 'html-minifier' options respectively; true means use default options of each minifiers

Usage Examples

Default Options

grunt.initConfig({
  dolphin-optimizer: {
    options: {
      srcPath: 'src',
      buildPath: 'build',
      embeded:'css',
      optimizeOptions:{
        //use 'uglify-js'
        js: true,
        //use 'clean-css'
        css: true,
        //use 'html-minifier'
        html:{ 
          removeComments: true
        }
      }
    },
  },
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)


上一篇:grunt-dpm
下一篇:grunt-preload
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部