metalsmith-prepack

0.0.2 • Public • Published

metalsmith-prepack

npm npm Dependency Status

metalsmith plugin for prepack.io

Installation

npm install metalsmith-prepack

Example

var Metalsmith = require('metalsmith');
var assets = require('metalsmith-assets');
var prepack = require('metalsmith-prepack');

var ms = Metalsmith(process.cwd());


ms.use(assets({
    source: './assets',
    destination: './assets',
}));


// no options are required, these are the defaults
//  i.e.  same as:  ms.use(prepack())  or  ms.use(prepack({}))
ms.use(prepack({
    
    // don't keep orignal file
    keep: false,
    
    // match javascript files
    // uses multimatch  https://www.npmjs.com/package/multimatch
    pattern: ['**/*.js'],
    
    // function for determining new filename
    // default function adds .min before the path.extname()
    outPath: function(filepath) {
        
        var ext = filepath.lastIndexOf(path.extname(filepath));
        
        return [
            filepath.substring(0, ext),
            '.min',
            filepath.substring(ext),
        ].join('');
        
    },
    
    // options to pass to prepack
    prepackOptions: {
        // https://prepack.io/getting-started.html#options
    },
    
}));


ms.build(function(error) {
    if (error) throw error;
    
    console.log('Built');
});

Sourcemaps

Support for input and output sourcemaps needs to be added.

Readme

Keywords

none

Package Sidebar

Install

npm i metalsmith-prepack

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • elijahk