
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@wordpress/custom-templated-path-webpack-plugin
Advanced tools
Webpack plugin for creating custom path template tags.
DEPRECATED for webpack v5: please use
output.filename
instead.
Webpack plugin for creating custom path template tags. Extend the default set of template tags with your own custom behavior. Hooks into Webpack's compilation process to allow you to replace tags with a substitute value.
Install the module
npm install @wordpress/custom-templated-path-webpack-plugin --save-dev
Note: This package requires Node.js 12.0.0 or later. It is not compatible with older versions. It works only with webpack v4.
Construct an instance of CustomTemplatedPathPlugin
in your Webpack configurations plugins
entry, passing an object where keys correspond to the template tag name. The value for each key is a function passed the original intended path and data corresponding to the asset.
The following example creates a new basename
tag to substitute the basename of each entry file in the build output file. When compiled, the built file will be output as build-entry.js
.
const { basename } = require( 'path' );
const CustomTemplatedPathPlugin = require( '@wordpress/custom-templated-path-webpack-plugin' );
module.exports = {
// ...
entry: './entry',
output: {
filename: 'build-[basename].js',
},
plugins: [
new CustomTemplatedPathPlugin( {
basename( path, data ) {
let rawRequest;
const entryModule = get( data, [ 'chunk', 'entryModule' ], {} );
switch ( entryModule.type ) {
case 'javascript/auto':
rawRequest = entryModule.rawRequest;
break;
case 'javascript/esm':
rawRequest = entryModule.rootModule.rawRequest;
break;
}
if ( rawRequest ) {
return basename( rawRequest );
}
return path;
},
} ),
],
};
For more examples, refer to Webpack's own TemplatedPathPlugin.js
, which implements the base set of template tags.
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.
FAQs
Webpack plugin for creating custom path template tags.
The npm package @wordpress/custom-templated-path-webpack-plugin receives a total of 713 weekly downloads. As such, @wordpress/custom-templated-path-webpack-plugin popularity was classified as not popular.
We found that @wordpress/custom-templated-path-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 25 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.