GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - WritePoetry/webpack-utils

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

@writepoetry/webpack-utils

Utility helpers for managing dynamic Webpack entry points in WordPress projects.
Built on top of @wordpress/scripts, this package simplifies handling of JavaScript and CSS/SCSS assets with flexible folder mapping and exclusions.


Using GitHub Packages

This package is hosted on GitHub Packages, not on the public npm registry.
That means you need to configure authentication before you can install or publish it.

Configure .npmrc

Create a file named .npmrc in your project root (or edit your global .npmrc) and add the following content:

@writepoetry:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN

Replace YOUR_GITHUB_TOKEN with a GitHub Personal Access Token that has at least:

  • read:packages to install,
  • write:packages to publish.

⚠️ Never commit .npmrc with a real token into your repository.

Installation

npm install @writepoetry/webpack-utils --save-dev

Requires @wordpress/scripts as a peer dependency.


Features

  • Dynamically collect assets (.js, .ts, .jsx, .tsx, .scss, .css) from your src directory.
  • Exclude specific folders from being processed.
  • Remap folder paths to custom namespaces.
  • Utility to detect --output-path from CLI arguments.
  • Excludes underscore-prefixed files and direcotries: Any file starting with _ (e.g., _variables.scss, _mixins.scss, _partial.js) is automatically skipped during asset collection.

API

getAllAssets(options = {})

Scans the project source path (from @wordpress/scripts) and builds an object of entry points.

Options:

  • excludeDirs: string[] Additional directories to exclude (default: ['blocks']).
  • remapDirs: Record<string,string> Mapping of directory prefixes to alternate names in the generated chunk keys.

Returns: Object.<string, string> — mapping of chunk names → absolute file paths.

Example:

const { getAllAssets } = require('@writepoetry/webpack-utils');

module.exports = {
  entry: {
    ...getAllAssets({
      excludeDirs: ['vendor'],
      remapDirs: {
        'js': 'scripts',
        'scss': 'styles',
      },
    }),
  },
};

getAsset(dir, { remapDirs } = {})

Processes files inside a specific directory. Only returns entries for supported extensions.

Arguments:

  • dir: string Absolute path to the directory to scan.
  • remapDirs: Record<string,string> (optional) Same mapping rules as in getAllAssets.

getOutputPathFromArgs()

Scans process.argv for --output-path=... and returns the value, or null if not found.


Example webpack.config.js

const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const { getAllAssets } = require('@writepoetry/webpack-utils');

module.exports = {
  ...defaultConfig,
  entry: {
    ...getAllAssets({
      remapDirs: {
        'js': 'scripts',
        'scss': 'styles',
      },
    }),
  },
};

License

This project is released under the MIT License — free to use, modify, and distribute for any purpose without restrictions.

MIT © WritePoetry

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.