grunt-inlines

1.1.3 • Public • Published

grunt-inlines

grunt-inlines helps you insert code which have been minified inline your file, it supports css and html files.

Usage

In your Gruntfile.js, write like below:

inlines: {
  options: {
    cssmin: true,
    htmlmin: true,
    htmlminOptions: {
      // Please references https://www.npmjs.com/package/html-minifier#options-quick-reference  
    }
  },
  files: {
    src: ...,
    dist: ...
  }
}

then, you can invoke function __inline in your javascript file, just like this:

// demo.js
// be sure that ./css/style.css exists
var styleCSS = __inline("./css/style.css")
var template = __inline("./html/footer.html")

and ./css/style.css file's content is:

.name {
  color: red;  
}

and ./html/footer.html file's content is:

<footer>
this is footer
</footer>

after compiled by grunt, demo.js would become:

var styleCSS = '.name{color:red}'
var template = '<footer>this is footer</footer>'

Package Sidebar

Install

npm i grunt-inlines

Weekly Downloads

1

Version

1.1.3

License

MIT

Last publish

Collaborators

  • sunxiaobo