grunt-glob

0.1.0 • Public • Published

grunt-glob

A grunt task that replaces <script> and <link> tags containing glob references on the filesystem with expanded tags.

Installation

Install as a dev dependency:

npm install grunt-glob --save-dev

Usage

Assuming the following filesystem...

src/
    index.html
dest/
    css/
        a.css
        b.css
    js/
        a.js
        b.js

... and given src/index.html...

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="./css/**/*.css">
</head>
<body>
    <script src="bower_components/jquery/jquery.js"></script> 
    <script src="./js/**/*.js"></script> 
</body>
</html>

... and the following grunt config...

glob: {
    files: {
        'dest/index.html': 'src/index.html'
    }
}

... running grunt glob will produce the following in dest/index.html...

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="css/a.css">
    <link rel="stylesheet" href="css/b.css">
</head>
<body>
    <script src="bower_components/jquery/jquery.js"></script> 
    <script src="js/a.js"></script> 
    <script src="js/b.js"></script> 
</body>
</html>

Why do I need this?

I use primarily for local development, transpiling ES6 modules to a temp directory, and then globbing all those transpiled files in my index.html file, rather than catting them all together.

Readme

Keywords

Package Sidebar

Install

npm i grunt-glob

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • bspoon