webpack-permissions-plugin
raw JSON → 1.0.10 verified Sat Apr 25 auth: no javascript maintenance
A webpack plugin to set file and directory permissions (chmod) on output files and folders. Currently at version 1.0.10 (last updated 2022), with infrequent releases. Tested with Webpack 2, 3, and 4. Supports both simple string paths and per-path mode configurations using octal strings or integers. Unlike generic chmod scripts, it integrates directly into the webpack build pipeline. Minimal dependencies; notable for its simplicity but lacks support for webpack 5 and has limited maintenance.
Common errors
error Error: Cannot find module 'webpack-permissions-plugin' ↓
cause Package not installed or typo in import.
fix
Run 'npm install -D webpack-permissions-plugin' and ensure correct require path.
error TypeError: PermissionsOutputPlugin is not a constructor ↓
cause Importing the module incorrectly (e.g., using ES import without default).
fix
Use 'const PermissionsOutputPlugin = require("webpack-permissions-plugin")'.
Warnings
gotcha Permissions may be overwritten by other plugins running after this one (e.g., CopyWebpackPlugin). ↓
fix Ensure PermissionsOutputPlugin is the last plugin in the plugins array.
breaking In v1.0.6, missing directories no longer cause build failure. If you relied on the error to catch missing paths, update your logic. ↓
fix Check directory existence manually if needed.
deprecated The package is no longer actively maintained; no webpack 5 support. ↓
fix Consider switching to a more modern plugin or a webpack 5-compatible alternative.
gotcha File permissions are applied after webpack's emit hook; any post-processing that changes file content may reset permissions. ↓
fix Apply this plugin as the last step.
gotcha The 'mode' option accepts octal strings or octal numbers; using decimal numbers will produce incorrect permissions. ↓
fix Always use '755' (string) or 0o755 (number), not 755 (decimal).
Install
npm install webpack-permissions-plugin yarn add webpack-permissions-plugin pnpm add webpack-permissions-plugin Imports
- PermissionsOutputPlugin wrong
import PermissionsOutputPlugin from 'webpack-permissions-plugin';correctconst PermissionsOutputPlugin = require('webpack-permissions-plugin'); - PermissionsOutputPlugin (in TypeScript) wrong
import * as PermissionsOutputPlugin from 'webpack-permissions-plugin';correctconst PermissionsOutputPlugin = require('webpack-permissions-plugin'); - PermissionsOutputPlugin (Webpack 5) wrong
Use with webpack 5 without shimcorrect// Not officially supported
Quickstart
const path = require('path');
const PermissionsOutputPlugin = require('webpack-permissions-plugin');
module.exports = {
plugins: [
new PermissionsOutputPlugin({
buildFolders: [
path.resolve(__dirname, 'dist')
],
buildFiles: [
path.resolve(__dirname, 'dist/app.js')
],
// defaults: fileMode: '755', dirMode: '644'
})
]
};