Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including metalsmith-webpack-2 with all npm packages installed. Try it out:

var metalsmithWebpack2 = require("metalsmith-webpack-2")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

metalsmith-webpack-2 v1.0.5

A webpack plugin for Metalsmith


npm github-issues stars forks

A webpack plugin for Metalsmith.

See the annotated source or github repo.


npm install metalsmith-webpack-2


import webpack from 'metalsmith-webpack-2'



options may be:

  • a webpack configuration object.
  • a path to your webpack configuration file
  • null / undefined, config will be read from webpack.config.js


Construct your webpack config exactly as you would if you were calling webpack from the command line.

  entry: {
    site: resolve(__dirname, 'src', 'js', 'site.js'),
  output: {
    path: resolve(__dirname, 'build', 'js'),
    filename: '[name].[chunkhash].js'

Note: It's important that absolute paths are provided to webpack, as is normal webpack behaviour. That means including your src and build directories as demonstrated above.

This example uses an asset's hash in it's filename (fingerprinting / cache busting). The filename for this asset will be stored in metalsmith meta, so you could access it from a template with something like:

<script src="{{webpack.assets['site']}}"></script>

This plugin will not ignore source files, you should use metalsmith-ignore for that

See the tests for more examples, or metalsmith-all-the-things for a full implementation.


$ npm test


MIT License, see LICENSE for details.

See Also


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free