MakeDirWebpackPlugin

raw JSON →
0.1.0 verified Sat Apr 25 auth: no javascript

A webpack plugin that creates directories during the compilation process. Version 0.1.0 is the latest stable release with no clear release cadence. It is useful when other plugins or loaders expect specific directories to exist (e.g., for output assets). Minimal configuration; niche alternative to using Node.js `mkdir` scripts.

gotcha Version 0.1.0 fixed nested directory creation; earlier versions may fail with nested paths.
fix Update to version 0.1.0 or later.
npm install make-dir-webpack-plugin
yarn add make-dir-webpack-plugin
pnpm add make-dir-webpack-plugin

Creates two directories ('dist/css' and 'dist/js') before webpack compilation runs.

const MakeDirWebpackPlugin = require('make-dir-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },
  plugins: [
    new MakeDirWebpackPlugin({
      dirs: [
        { path: './dist/css' },
        { path: './dist/js' }
      ]
    })
  ]
};