Webpack Permissions Plugin GitHub repository showing its source files and project overview
Webpack Permissions Plugin GitHub repository showing its source files and project overview

Webpack Permissions Plugin

A webpack plugin to manage the filesystem permissions of output files and directories.

Set permissions in webpack

Webpack Permissions Plugin applies file modes after webpack finishes. Give it an output path and an octal mode, much like chmod.

I published it in June 2017 because copied build artifacts do not always keep the permissions they need. A shell script can lose its execute bit, while a server entry point can end up too open. A post-build command fixes that, but it can drift from the webpack config or break when an output path changes. Keeping paths and modes in webpack puts the fix beside the artifact in local builds, CI and release packaging.

Use it like chmod

Install it with npm install --save-dev webpack-permissions-plugin. This config does the same job as chmod 755 dist/server.js:

import PermissionsOutputPlugin from 'webpack-permissions-plugin';

export default {
  plugins: [
    new PermissionsOutputPlugin({
      buildFiles: [{ path: 'dist/server.js', fileMode: 0o755 }],
    }),
  ],
};

buildFiles changes named files. buildFolders walks a directory and accepts separate modes for its files and subdirectories. Since buildFiles runs afterwards, it can override the mode for one file. The modes use the same owner, group and other bits as Node.

Apply modes after the build

The plugin uses webpack’s done compiler hook, when webpack and other plugins have finished writing files. It then calls fs.chmodSync() on the configured paths. It does not start a shell or depend on GNU tools.

POSIX read, write and execute bits work on Unix-like systems. On Windows, Node can only change the write bit, so the plugin cannot provide full POSIX permission behavior there.

More than 11.2 million downloads

I published the first npm version on 13 June 2017. By August 2026, npm's daily figures added up to more than 11.2 million downloads, with over 300,000 monthly installs at its peak.

Across eleven npm versions, the public API has stayed focused on paths and modes. Most releases handled webpack changes. The plugin still does the same job it did in 2017.