npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-assetser

v1.1.1

Published

Inserting the contents of external CSS and JavaScript files directly into the HTML document

Downloads

29

Readme

grunt-assetser

Inserting the contents of external CSS and JavaScript files directly into the HTML document.

Travis NPM version devDependency Status devDependency Status

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as 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-assetser --save-dev

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

grunt.loadNpmTasks('grunt-assetser');

The assetser task

Run this task with the grunt assetser command.

Task targets, files and options may be specified according to the Grunt Configuring tasks guide.

Options

options.assetsDir (required)

Type: String Default: empty string

This string will be used as the path to the resources that will be added in the HTML files. This is a required parameter!

options.onlyMarked

Type: String Boolean Default: false

Add only those files that contain in its name, the specified string.

If you choose true, then will be used value ._inline.

options.onlyType

Type: String Default: empty string

Add only files the type specified by in this parameter. Supported: js, css.

options.verbose

Type: Boolean Default: true

Display information about the processed files.

Running "assetser:default_options" (assetser) task
>> The file tmp/default.html has been successfully created.
>> The file tmp/default_tab.html has been successfully created.

Example of work

Before

// assets/file.js
( function () { ... } )();
// assets/file.css
.class { ... }

After

<!doctype html>
<html lang="en">
  <head>
    ...
    <style>.class{ ... }</style>
  </head>
  <body>
    ...
    <script>(function(){ ... })();</script>
  </body>
</html>

Usage Examples

Working with one HTML file

grunt.initConfig({
  assetser: {
    main: {
      options: {
        assetsDir: 'app/assets'
      },
      // like this
      files: {
        'build/index.html': 'app/index.html',
        'tmp/test.html': 'app/index.html'
      }
      // or
      src: 'app/index.html',
      dest: 'build/index.html'
    }
  }
});

Working with multiple HTML files

grunt.initConfig({
  assetser: {
    main: {
      options: {
        assetsDir: 'app/assets'
      },
      files: [{
        expand: true,
        cwd: 'app',
        src: '*.html',
        dest: 'build'
      }]
    }
  }
});

Working with multiple assets directories

grunt.initConfig({
  assetser: {
    main: {
      options: {
        assetsDir: ['app/assets/styles', 'app/assets/scripts']
      },
      files: [{
        expand: true,
        cwd: 'app',
        src: '*.html',
        dest: 'tmp'
      }]
    }
  }
});

Release History

  • 2016-02-22 v1.1.1 Compatibility with Grunt version 1.0.0.
  • 2015-12-27 v1.1.0 Verbose option and overwrite the content instead of adding at the end
  • 2015-11-01 v1.0.0 Optimization of combination of resource files
  • 2015-10-31 v0.1.5 Cleaning code
  • 2015-09-13 v0.1.4 Added XO
  • 2015-09-09 v0.1.3 Refactoring and tests by Ava
  • 2015-07-27 v0.1.2 Automatic definition of the head tag nesting in html
  • 2015-07-24 v0.1.1 Fix errors when working with multiple assets directories
  • 2015-07-24 v0.1.0 Initialization