2.0.3 • Published 7 years ago

grunt-wooha-html v2.0.3

Weekly downloads
1
License
-
Repository
github
Last release
7 years ago

grunt-wooha-html

self fed dev craft with bower,grunt,require HTML build plugin.

this plugin is used for version control,html compress,js\css inject.

Update log

  • Version 2.0.2 add module.exports support with browserify

Getting Started

This plugin requires Grunt ~0.4.5

npm install grunt-wooha-html --save-dev

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

grunt.loadNpmTasks('grunt-wooha-html');

The "wooha_html" task

Overview

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

    grunt.initConfig({
    	wooha_html: {
	      options: {
	      
	      }
  		}
  	});

inject script or stylesheet

If you want inject some js or css file in html, You just need add a "inject" attribute on script tag of html.

	<script src="***" inject></script>
	<link rel="stylesheet" type="text/css" href="***" inject>

Options Quick Reference

OptionDescriptionDefault
exportModeis this project use 1:module.exports or 2:CMD or 3:react1
envwhich environment build for'pro'
buildgrunt build folder'build'
versionversion code'' with out version control
mainpage main js fileindex.js
beautifybeautify html filefalse
minifyhtml-minifier options.The minify option is useless when option beautify is true.More information seehtml-minifierobject

Usage

CommonJS mode

  wooha_html: {
      dist: {
        cwd: './demo/',
        src: ['**/*.html', '!**/*.jst.html'],
        dest: './html/',
        options: {
          version: '<%= version %>',
          env: '<%= env %>',
          build: "<%= buildBase %>",
          src: "<%= srcBase %>",
          main: "index",
          exportMode: 2,
          minify: {
              preserveLineBreaks: true,
              minifyCSS: true,
              minifyJS: true,
              maxLineLength: 1024
          },
          beautify: false
        }
      }
  }

Browserify module.exports mode

    wooha_html: {
      dist: {
        cwd: './demo/',
        src: ['**/*.html', '!**/*.jst.html'],
        dest: './html/',
        options: {
          exportMode: 1,
          version: '<%= version %>',
          minify: {
              preserveLineBreaks: true,
              minifyCSS: true,
              minifyJS: true,
              maxLineLength: 1024
          },
          processContent: function (html) {
            /*
            * 统计代码注入
            * */
            return html;
          }
        }
      }
    }

React web mode

    wooha_html: {
      dist: {
        cwd: './demo/',
        src: ['**/*.html', '!**/*.jst.html', "!ueditor/**/*.html"],
        dest: './html/',
        options: {
          version: '<%= version %>',
          exportMode: 3,
          minify: {
              preserveLineBreaks: true,
              minifyCSS: true,
              minifyJS: true,
              maxLineLength: 1024
          },
          beautify: true,
          processContent: function (html) {
            /*
            * 统计代码注入
            * */
            return html;
          }
        }
      }
    }

Project orga

  • root - build -- build code folder
    • html -- built html folder
    • demo -- dev html folder
    • src
      • c -- lib folder
      • p -- page folder

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)

2.0.3

7 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago