# webpack-php-asset-versioning

> *A simple Webpack plugin to produce a php class with the timestamp of each build; used to 'version' your asset files for cache-busting*

Latest version **1.0.3** (published 2019-07-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install webpack-php-asset-versioning
pnpm add webpack-php-asset-versioning
yarn add webpack-php-asset-versioning
bun add webpack-php-asset-versioning
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-07-06 |
| First published | 2019-07-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Inigo Pascall |
| Maintainers | inigopascall |

## Links

- npm: https://www.npmjs.com/package/webpack-php-asset-versioning
- npm.io page: https://npm.io/package/webpack-php-asset-versioning

## Dependencies (1)

- [fs](https://npm.io/package/fs.md) 0.0.1-security

## Recent versions

- 1.0.3 (latest) — 2019-07-06
- 1.0.2 — 2019-07-05
- 1.0.1 — 2019-07-03
- 1.0.0 — 2019-07-02

## README

# Webpack Asset Versioning - Inigo Pascall

*A simple Webpack plugin to produce a php class with the timestamp of each build; used to 'version' your asset files for cache-busting*

## Usage

### Install : 
```js
npm install --save-dev webpack-asset-versioning
```

## Configure webpack.config.js

### Import:

```js
const AssetVersioning = require('webpack-php-asset-versioning');
```

### Configure plugin:

```js
    plugins: [
		// ...
        new AssetVersioning({
            // options
        })
    ]
```

## Set options:

- **file_name** *the full path of the outputted php file*
- **class_name** *the name of the php class*

| Key        | Determines                                | Default                |
| ---------- | ----------------------------------------- | ---------------------- |
| file_name  | *the full path of the outputted php file* | `./assets.version.php` |
| class_name | *the name of the php class*               | `AssetsVersion`        |

### eg:

```js
    plugins: [
        new AssetVersioning({
            file_name: '../assets.version.php',
            class_name: 'BuildDate'
        })
    ]
```

### Produces

`assets.version.php` :

```php
<?php

class BuildDate {
	public $current = 1562363854500;
}
```



------

## Include in your php app

```php
include_once 'assets.version.php';
$assets_version = (new \AssetsVersion())->current;
```

### Laravel
*(I prefer to use a custom Webpack configuration rather than Laravel Mix. Thus I can include this in my app by loading within `AppServiceProvider.php`):*

```php
    public function boot()
    {
        include_once base_path() . '/assets.version.php';
        $assets_version = (new \AssetsVersion())->current;
        View::share('assets_version', $assets_version);
    }
```

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