# webpack-php-manifest

> Writes output file names to a PHP file.

Latest version **0.0.9** (published 2022-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-php-manifest
pnpm add webpack-php-manifest
yarn add webpack-php-manifest
bun add webpack-php-manifest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2022-01-26 |
| First published | 2017-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Gabe Blair |
| Maintainers | castiron-owner |
| Keywords | webpack, php |

## Links

- npm: https://www.npmjs.com/package/webpack-php-manifest
- Repository: https://github.com/castiron/webpack-php-manifest
- Issues: https://github.com/castiron/webpack-php-manifest/issues
- npm.io page: https://npm.io/package/webpack-php-manifest

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.9 (latest) — 2022-01-26
- 0.0.8 — 2020-03-11
- 0.0.7 — 2020-03-11
- 0.0.6 — 2020-03-11
- 0.0.5 — 2018-02-06
- 0.0.4 — 2017-08-07
- 0.0.3 — 2017-05-18
- 0.0.2 — 2017-05-18
- 0.0.1 — 2017-05-18

## README

## PHP Manifest from Webpack

_Please note this module depends on webpack 4+._

This webpack plugin will create a PHP file in your `output.path` directory with a PHP class in it having two static
attributes: `$jsFiles` and `$cssFiles`. These can be accessed by your PHP application to learn about what to include
when rendering the frontend of the site.

Note that the php manifest is created with (node fs)[https://nodejs.org/api/fs.html] independently of the Webpack
output cycle. It will therefor be created in the same location when running a standard Webpack build *or* Webpack Dev Server

### Install

With Yarn:

```
yarn add webpack-php-manifest
```

With NPM:

```
npm i webpack-php-manifest
```

### Usage
```javascript
// ...in your webpack config file

const PhpManifestPlugin = require('webpack-php-manifest');
const phpManifest = new PhpManifestPlugin(options);

module.exports = {
  // ...
  plugins: [
    phpManifest
  ]
}
```

## Available options:

`output` (default: "assets-manifest")

The name of the manifest file to write. Will be written to webpack's
`output.path` directory and appended with `.php`.

&nbsp;&nbsp;

`path` (default: "")

The relative file path to the asset files. Example:
```javascript
const phpManifest = new PhpManifestPlugin({
  path: assets // Asset path will look like /assets/bundle.js
});
```

&nbsp;&nbsp;

`pathPrefix` (default: "")

An optional absolute URL, that is prepended the asset file paths in php.
Primarily used with the `devServer` option below.

&nbsp;&nbsp;

`devServer` (default: false)

A flag that tells the plugin if webpack-dev-server is running, and adds
`webpack-dev-server.js` to the list of JS assets in the file list.

If used, this should be passed as part of an environment or config variable.
pathPrefix should also be used to point to the devServer url. Example:
```javascript
const phpManifest = new PhpManifestPlugin({
  devServer: process.env.WEBPACK_DEV_SERVER, // This should be an env or config boolean
  // In this example, path prefix is included conditionally so that the prefix is only used when dev server is running
  pathPrefix:
  process.env.WEBPACK_DEV_SERVER ? `http://localhost:${port}` : null
  });
  ```

  &nbsp;&nbsp;

  `phpClassName` (default: "WebpackBuiltFiles")

  The PHP class name to use for the class. You can generally ignore this
  unless you have a conflicting PHP class named `\WebpackBuiltFiles` in your PHP environment.

  ## Consuming the manifest

  Currently there's only one implementation for consuming the generated manifest in a PHP application:

  #### October CMS

  Use the October CMS plugin called [webpackassets-plugin](https://packagist.org/packages/castiron/webpackassets-plugin).

---
_Source: https://npm.io/package/webpack-php-manifest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
