metalsmith-webpack

raw JSON →
1.0.3 verified Sat Apr 25 auth: no javascript abandoned

A webpack plugin for Metalsmith, version 1.0.3. This package integrates webpack into the Metalsmith build pipeline, allowing you to process JavaScript bundles as part of your static site generation. It requires both webpack and Metalsmith as peer dependencies. Compared to other build tools, it leverages webpack's full configuration, making it suitable for complex asset pipelines. However, the package is currently unmaintained (last update 2015) and relies on an outdated webpack 1.x API. May still work with modern webpack via compatibility layers, but use caution.

error Cannot find module 'metalsmith-webpack'
cause Package not installed or not in node_modules.
fix
Run 'npm install metalsmith-webpack' and ensure it's in your dependencies.
error TypeError: webpack is not a function
cause Incorrect import style; package exports a function but may be imported as object.
fix
Use the correct import: const webpack = require('metalsmith-webpack');
breaking Requires webpack 1.x, incompatible with webpack 2+ without adapter.
fix Use webpack 1.x or fork the package to upgrade.
deprecated Package has not been updated since 2015; likely abandoned.
fix Consider alternatives like metalsmith-uglify or manual webpack integration.
gotcha Options object is passed directly to webpack without normalization; some webpack configurations may behave differently.
fix Refer to webpack 1.x configuration documentation.
npm install metalsmith-webpack
yarn add metalsmith-webpack
pnpm add metalsmith-webpack

Demonstrates basic usage integrating webpack into a Metalsmith build pipeline.

const Metalsmith = require('metalsmith');
const webpack = require('metalsmith-webpack');
const path = require('path');

Metalsmith(__dirname)
  .use(webpack({
    context: path.resolve(__dirname, './src/js/'),
    entry: './index.js',
    output: {
      path: '/js',
      filename: 'bundle.js'
    }
  }))
  .build((err) => {
    if (err) throw err;
  });