This commit is contained in:
Tutur33
2023-11-24 23:58:26 +01:00
parent 25395c0ee1
commit 938ad9d309
4191 changed files with 41 additions and 518781 deletions
-239
View File
@@ -1,239 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning].
[Semantic Versioning]: http://semver.org/
## 7.0.0 - 2020-12-11
* Requires webpack 5 or greater as a peer dependency
* Closes [#322](https://github.com/ztoben/assets-webpack-plugin/issues/322)
## 6.1.2 - 2020-12-08
* Closes [#319](https://github.com/ztoben/assets-webpack-plugin/issues/319)
## 6.1.1 - 2020-12-03
* Adds the `includeDynamicImportedAssets` option
* Closes [#313](https://github.com/ztoben/assets-webpack-plugin/issues/313)
## 6.1.0 - 2020-12-03
* Closes [#312](https://github.com/ztoben/assets-webpack-plugin/issues/312)
## 6.0.6 - 2020-12-02
* Adds [#311](https://github.com/ztoben/assets-webpack-plugin/pull/311)
* Fixes issue where default path would not be set
## 6.0.5 - 2020-12-01
* Adds [#310](https://github.com/ztoben/assets-webpack-plugin/pull/310)
## 6.0.4 - 2020-11-13
* Adds the `includeAuxiliaryAssets` option
* Closes [#302](https://github.com/ztoben/assets-webpack-plugin/issues/302)
## 6.0.2 - 2020-10-16
* Closes [#279](https://github.com/ztoben/assets-webpack-plugin/issues/279)
## 6.0.1 - 2020-10-15
* Initial webpack 5 support
* Versions going forward will support webpack 5 only
## 6.0.0
* This release is deprecated.
## 5.1.2 - 2020-09-22
* Add a new option to include assets that aren't in any chunk using the `includeFilesWithoutChunk` option.
* Closes [#204](https://github.com/ztoben/assets-webpack-plugin/issues/204)
## 5.1.1 - 2020-08-17
* Allow more than one entry in `includeManifest`.
* Closes [#84](https://github.com/ztoben/assets-webpack-plugin/issues/84)
## 5.1.0 - 2020-08-17
* Implements using more relaxed dependencies.
* Fixes [#240](https://github.com/ztoben/assets-webpack-plugin/issues/240)
## 5.0.5 - 2020-08-17
* Plugin will now parse the `.mjs` file extension.
## 5.0.4 - 2020-08-14
* Fixes [#251](https://github.com/ztoben/assets-webpack-plugin/issues/251)
## 5.0.3 - 2020-07-09
* Bumps several dependencies.
## 5.0.2 - 2020-06-15
* Fixes an error when `keepInMemory` was turn on.
## 5.0.1 - 2020-06-15
* Fixes [#234](https://github.com/ztoben/assets-webpack-plugin/issues/234)
## 5.0.0 - 2020-06-11
* Unfortunately must bump to v5 instead of v4 due to an old botched release that can't be unpublished
* Major bump due to now requiring node 10
* Maintains the same changes as `3.10.0`, but properly warns when using an older version of node
## 3.10.0 - 2020-06-08 (Deprecated)
* Updates several dependencies
* Fixes [#226](https://github.com/ztoben/assets-webpack-plugin/issues/226)
## 3.9.10 - 2019-02-28
* Fixes [#169](https://github.com/ztoben/assets-webpack-plugin/issues/169)
## 3.9.9 - 2019-02-28
* Adds the `integrity` option to add output from webpack-subresource-integrity to the json file
* Fixes [#63](https://github.com/ztoben/assets-webpack-plugin/issues/63)
## 3.9.8 - 2019-02-27
* Dependency updates
* Fixes [#167](https://github.com/ztoben/assets-webpack-plugin/issues/167)
## 3.9.7 - 2018-10-04
* Allow webpack 4 entrypoints chunks
* Fixes [#108](https://github.com/ztoben/assets-webpack-plugin/issues/108)
## 3.9.6 - 2018-08-20
* Fixes [#125](https://github.com/ztoben/assets-webpack-plugin/issues/125)
## 3.9.5 - 2018-08-09
* Adds the `keepInMemory` option to toggle whether you want the assets file generated when running in `webpack-dev-server`.
## 3.9.4 - 2018-08-08
* Adds the `includeAllFileTypes`, and `fileTypes` options for controlling which files are included in the assets file.
## 3.9.3 - 2018-08-07
* Fixes an issue where `useCompilerPath` wasn't correctly resolving the path.
## 3.9.2 - 2018-08-07
* Reverts [#109](https://github.com/ztoben/assets-webpack-plugin/pull/109), fixes [#118](https://github.com/ztoben/assets-webpack-plugin/issues/118).
## 3.9.1 - 2018-08-06
* `useCompilerPath` option to override path with webpack output path set in config.
## 3.9.0 - 2018-08-06
* ~~Now supports webpack 4 entries with multiple chunks. See [#109](https://github.com/ztoben/assets-webpack-plugin/pull/109) for details.~~
* Use compiler.outputFileSystem for output.
* Fixes [#108](https://github.com/ztoben/assets-webpack-plugin/issues/108), [#111](https://github.com/ztoben/assets-webpack-plugin/issues/111), and [#92](https://github.com/ztoben/assets-webpack-plugin/issues/92).
## 3.8.4 - 2018-06-20
### Changed
* No code changed. Purely for testing tagged releases on git.
## 3.8.3 - 2018-06-18
### Changed
* Package json was pointing to the wrong index file.
## 3.8.2 - 2018-06-18
### Changed
* Add babel to the build process.
## 3.8.1 - 2018-06-18
### Changed
* Support for listing the manifest entry first when `manifestFirst` option is set. See [#66](https://github.com/ztoben/assets-webpack-plugin/issues/66) for details.
## 3.8.0 - 2018-06-15
### Changed
* Reverts [#90](https://github.com/ztoben/assets-webpack-plugin/pull/90), fixes [#93](https://github.com/ztoben/assets-webpack-plugin/issues/93) and [#92](https://github.com/ztoben/assets-webpack-plugin/issues/92)
## 3.7.2 - 2018-06-14
### Changed
* Reduces npm package size [#67](https://github.com/ztoben/assets-webpack-plugin/issues/67)
## 3.7.1 - 2018-06-13
### Changed
* Fixes a parsing error with the asset path introduced by the fix for [#88](https://github.com/ztoben/assets-webpack-plugin/issues/88)
## 3.7.0 - 2018-06-13
### Changed
* Adds all assets to the manifest that aren't in a chunk (kudos to [@Kronuz](https://github.com/Kronuz) see [#65](https://github.com/ztoben/assets-webpack-plugin/pull/65))
## 3.6.3 - 2018-06-13
### Changed
* Add support for multiple files of the same extension (kudos to [@aaronatmycujoo](https://github.com/aaronatmycujoo) see [#79](https://github.com/ztoben/assets-webpack-plugin/pull/79) and [@Kronuz](https://github.com/Kronuz) see [#64](https://github.com/ztoben/assets-webpack-plugin/pull/64))
## 3.6.2 - 2018-06-13
### Changed
* Fixed incorrect concatination of asset file names and directory path see [#88](https://github.com/ztoben/assets-webpack-plugin/issues/88)
## 3.6.1 - 2018-06-13
### Changed
* webpack-dev-server (which uses memory-fs) correctly generates the manifest inside the memory file system (kudos to [@Kronuz](https://github.com/Kronuz) see [#90](https://github.com/ztoben/assets-webpack-plugin/pull/90))
## 3.6.0 - 2018-05-29
### Changed
* webpack 4 support (kudos to [@ztoben](https://github.com/ztoben) and [@saveman71](https://github.com/saveman71) see [#89](https://github.com/ztoben/assets-webpack-plugin/pull/89))
## 3.5.1 - 2017-01-20
### Fixed
* Support for source maps when `includeManifest` option is set.
## 3.5.0 - 2016-10-21
### Added
* `includeManifest` option (kudos to Matt Krick [@mattkrick](https://github.com/mattkrick)).
[See docs](./README.md#includemanifest) for more details.
## 3.4.0 - 2016-03-09
### Changed
* Do not write to assets file if output hasn't changed.
## 3.2.0 - 2015-11-17
### Added
* `processOutput` option.
## 3.1.0 - 2015-10-24
### Added
* Config now accepts a `fullPath` option.
-216
View File
@@ -1,216 +0,0 @@
const fs = require('fs')
const path = require('path')
const _ = require('lodash')
const getAssetKind = require('./lib/getAssetKind')
const isHMRUpdate = require('./lib/isHMRUpdate')
const isSourceMap = require('./lib/isSourceMap')
const getDynamicImportedChildAssets = require('./lib/getDynamicImportedChildAssets')
const createQueuedWriter = require('./lib/output/createQueuedWriter')
const createOutputWriter = require('./lib/output/createOutputWriter')
function AssetsWebpackPlugin (options) {
this.options = _.merge({}, {
filename: 'webpack-assets.json',
prettyPrint: false,
update: false,
fullPath: true,
manifestFirst: true,
useCompilerPath: false,
fileTypes: ['js', 'css'],
includeAllFileTypes: true,
includeFilesWithoutChunk: false,
includeAuxiliaryAssets: false,
includeDynamicImportedAssets: false,
keepInMemory: false,
integrity: false,
removeFullPathAutoPrefix: false
}, options)
}
AssetsWebpackPlugin.prototype = {
constructor: AssetsWebpackPlugin,
apply: function (compiler) {
const self = this
self.options.path = path.resolve(
self.options.useCompilerPath
? (compiler.options.output.path || '.')
: (self.options.path || '.')
)
self.writer = createQueuedWriter(createOutputWriter(self.options))
const afterEmit = (compilation, callback) => {
const options = compiler.options
const stats = compilation.getStats().toJson({
hash: true,
publicPath: true,
assets: true,
chunks: false,
modules: false,
source: false,
errorDetails: false,
timings: false
})
let assetPath = (stats.publicPath && self.options.fullPath) ? stats.publicPath : ''
// assetsByChunkName contains a hash with the bundle names and the produced files
// e.g. { one: 'one-bundle.js', two: 'two-bundle.js' }
// in some cases (when using a plugin or source maps) it might contain an array of produced files
// e.g. {
// main:
// [ 'index-bundle-42b6e1ec4fa8c5f0303e.js',
// 'index-bundle-42b6e1ec4fa8c5f0303e.js.map' ]
// }
// starting with webpack 5, the public path is automatically determined when possible and the path is prefaced
// with `/auto/`, the `removeAutoPrefix` option can be set to turn this off
if (self.options.removeFullPathAutoPrefix) {
if (assetPath.startsWith('auto')) {
assetPath = assetPath.substring(4)
}
}
const seenAssets = {}
let chunks
if (self.options.entrypoints) {
chunks = Object.keys(stats.entrypoints)
if (self.options.includeFilesWithoutChunk) {
chunks.push('') // push "unnamed" chunk
}
} else {
chunks = Object.keys(stats.assetsByChunkName)
chunks.push('') // push "unnamed" chunk
}
const output = chunks.reduce(function (chunkMap, chunkName) {
let assets
if (self.options.entrypoints) {
assets = chunkName ? stats.entrypoints[chunkName].assets : stats.assets
} else {
assets = chunkName ? stats.assetsByChunkName[chunkName] : stats.assets
}
if (self.options.includeAuxiliaryAssets && chunkName && stats.entrypoints[chunkName].auxiliaryAssets) {
assets = [...assets, ...stats.entrypoints[chunkName].auxiliaryAssets]
}
if (self.options.includeDynamicImportedAssets && chunkName && stats.entrypoints[chunkName].children) {
const dynamicImportedChildAssets = getDynamicImportedChildAssets(options, stats.entrypoints[chunkName].children)
assets = [...assets, ...dynamicImportedChildAssets]
}
if (!Array.isArray(assets)) {
assets = [assets]
}
let added = false
const typeMap = assets.reduce(function (typeMap, obj) {
const asset = obj.name || obj
if (isHMRUpdate(options, asset) || isSourceMap(options, asset) || (!chunkName && seenAssets[asset])) {
return typeMap
}
const typeName = getAssetKind(options, asset)
if (self.options.includeAllFileTypes || self.options.fileTypes.includes(typeName)) {
const combinedPath = assetPath && assetPath.slice(-1) !== '/' ? `${assetPath}/${asset}` : assetPath + asset
const type = typeof typeMap[typeName]
const compilationAsset = compilation.assets[asset]
const integrity = compilationAsset && compilationAsset.integrity
const loadingBehavior = obj.loadingBehavior
if (type === 'undefined') {
typeMap[typeName] = combinedPath
if (self.options.integrity && integrity) {
typeMap[typeName + 'Integrity'] = integrity
}
} else {
if (type === 'string') {
typeMap[typeName] = [typeMap[typeName]]
}
if (self.options.includeDynamicImportedAssets && loadingBehavior) {
const typeNameWithLoadingBehavior = typeName + ':' + loadingBehavior
typeMap[typeNameWithLoadingBehavior] = typeMap[typeNameWithLoadingBehavior] || []
typeMap[typeNameWithLoadingBehavior].push(combinedPath)
} else {
typeMap[typeName].push(combinedPath)
}
}
added = true
seenAssets[asset] = true
}
return typeMap
}, {})
if (added) {
chunkMap[chunkName] = typeMap
}
return chunkMap
}, {})
let manifestNames = self.options.includeManifest === true ? ['manifest'] : self.options.includeManifest
if (typeof manifestNames === 'string') {
manifestNames = [manifestNames]
}
if (manifestNames) {
for (let i = 0; i < manifestNames.length; i++) {
const manifestName = manifestNames[i]
const manifestEntry = output[manifestName]
if (manifestEntry) {
let js = manifestEntry.js || manifestEntry.mjs
if (!Array.isArray(js)) {
js = [js]
}
const manifestAssetKey = js[js.length - 1].substr(assetPath.length)
const parentSource = compilation.assets[manifestAssetKey]
const entryText = parentSource.source()
if (!entryText) {
throw new Error('Could not locate manifest function in source', parentSource)
}
manifestEntry.text = entryText
}
}
}
if (self.options.metadata) {
output.metadata = self.options.metadata
}
if (!compiler.outputFileSystem.readFile) {
compiler.outputFileSystem.readFile = fs.readFile.bind(fs)
}
if (!compiler.outputFileSystem.join) {
compiler.outputFileSystem.join = path.join.bind(path)
}
self.writer(compiler.outputFileSystem, output, function (err) {
if (err) {
compilation.errors.push(err)
}
callback()
})
}
if (compiler.hooks) {
const plugin = { name: 'AssetsWebpackPlugin' }
compiler.hooks.afterEmit.tapAsync(plugin, afterEmit)
} else {
compiler.plugin('after-emit', afterEmit)
}
}
}
module.exports = AssetsWebpackPlugin
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 Zach Toben
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-58
View File
@@ -1,58 +0,0 @@
{
"name": "assets-webpack-plugin",
"version": "7.0.0",
"description": "Emits a json file with assets paths",
"main": "dist/index.js",
"engines": {
"node": ">=10.x.x"
},
"scripts": {
"lint": "standard --verbose | snazzy",
"fix-lint": "standard --fix",
"test": "mocha test",
"build": "babel index.js --out-dir dist && babel lib --out-dir dist/lib",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "https://github.com/ztoben/assets-webpack-plugin.git"
},
"keywords": [
"webpack",
"plugin",
"generate",
"assets",
"hashes"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/ztoben/assets-webpack-plugin/issues"
},
"homepage": "https://github.com/ztoben/assets-webpack-plugin",
"files": [
"index.js",
"dist/"
],
"devDependencies": {
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"babel-preset-env": "1.7.0",
"chai": "4.2.0",
"css-loader": "5.0.1",
"mini-css-extract-plugin": "1.3.3",
"mocha": "8.2.1",
"rimraf": "3.0.2",
"snazzy": "9.0.0",
"standard": "16.0.3",
"style-loader": "2.0.0",
"webpack": "5.10.0"
},
"dependencies": {
"camelcase": "^6.0.0",
"escape-string-regexp": "^4.0.0",
"lodash": "^4.17.20"
},
"peerDependencies": {
"webpack": ">=5.0.0"
}
}
-443
View File
@@ -1,443 +0,0 @@
# assets-webpack-plugin
[![version](https://img.shields.io/npm/v/assets-webpack-plugin.svg)](https://npmjs.org/package/assets-webpack-plugin)
[![downloads](https://img.shields.io/npm/dt/assets-webpack-plugin.svg)](https://npmjs.org/package/assets-webpack-plugin)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/ztoben/assets-webpack-plugin.svg?branch=master)](https://travis-ci.org/ztoben/assets-webpack-plugin)
[![Build status](https://ci.appveyor.com/api/projects/status/sbchndv12vk45mo3?svg=true)](https://ci.appveyor.com/project/ztoben/assets-webpack-plugin)
Webpack plugin that emits a json file with assets paths.
## Table of Contents
* [Install](#install)
* [Why Is This Useful?](#why-is-this-useful)
* [Example output:](#example-output)
* [Configuration](#configuration)
* [Options](#options)
* [`filename`](#filename)
* [`fullPath`](#fullpath)
* [`removeFullPathAutoPrefix`](#removefullpathautoprefix)
* [`includeManifest`](#includemanifest)
* [`manifestFirst`](#manifestfirst)
* [`path`](#path)
* [`useCompilerPath`](#usecompilerpath)
* [`prettyPrint`](#prettyprint)
* [`processOutput`](#processoutput)
* [`update`](#update)
* [`metadata`](#metadata)
* [`includeAllFileTypes`](#includeallfileTtypes)
* [`fileTypes`](#filetypes)
* [`keepInMemory`](#keepinmemory)
* [`integrity`](#integrity)
* [`entrypoints`](#entrypoints)
* [`includeFilesWithoutChunk`](#includefileswithoutchunk)
* [Using in multi-compiler mode](#using-in-multi-compiler-mode)
* [Using this with Rails](#using-this-with-rails)
* [Using this with ASP.NET Core](#using-this-with-aspnet-core)
* [Test](#test)
## Install
⚠️ Starting with version 6, this plugin works with Webpack 5+.
If you are working with an older version of Webpack, you can use the most recent 5.x.x release (`5.1.2`).
```sh
npm install assets-webpack-plugin --save-dev
```
If you're using Webpack 4 or below:
```sh
npm install webpack-assets-manifest@5.1.2 --save-dev
```
## Why Is This Useful?
When working with Webpack you might want to generate your bundles with a generated hash in them (for cache busting).
This plug-in outputs a json file with the paths of the generated assets so you can find them from somewhere else.
### Example output:
The output is a JSON object in the form:
```json
{
"bundle_name": {
"asset_kind": "/public/path/to/asset"
}
}
```
Where:
* `"bundle_name"` is the name of the bundle (the key of the entry object in your webpack config, or "main" if your entry is an array).
* `"asset_kind"` is the camel-cased file extension of the asset
For example, given the following webpack config:
```js
{
entry: {
one: ['src/one.js'],
two: ['src/two.js']
},
output: {
path: path.join(__dirname, "public", "js"),
publicPath: "/js/",
filename: '[name]_[hash].bundle.js'
}
}
```
The plugin will output the following json file:
```json
{
"one": {
"js": "/js/one_2bb80372ebe8047a68d4.bundle.js"
},
"two": {
"js": "/js/two_2bb80372ebe8047a68d4.bundle.js"
}
}
```
## Configuration
In your webpack config include the plug-in. And add it to your config:
```js
var path = require('path')
var AssetsPlugin = require('assets-webpack-plugin')
var assetsPluginInstance = new AssetsPlugin()
module.exports = {
// ...
output: {
path: path.join(__dirname, "public", "js"),
filename: "[name]-bundle-[hash].js",
publicPath: "/js/"
},
// ....
plugins: [assetsPluginInstance]
}
```
### Options
You can pass the following options:
#### `filename`
Optional. `webpack-assets.json` by default.
Name for the created json file.
```js
new AssetsPlugin({filename: 'assets.json'})
```
#### `fullPath`
Optional. `true` by default.
If `false` the output will not include the full path
of the generated file.
```js
new AssetsPlugin({fullPath: false})
```
e.g.
`/public/path/bundle.js` vs `bundle.js`
#### `removeFullPathAutoPrefix`
Optional. `false` by default.
If `true` the full path will automatically be stripped of the `/auto/` prefix generated by webpack.
```js
new AssetsPlugin({removeFullPathAutoPrefix: true})
```
e.g.
`/public/path/bundle.js` vs `bundle.js`
#### `includeManifest`
Optional. `false` by default.
Inserts the manifest javascript as a `text` property in your assets.
Accepts the name or names of your manifest chunk. A manifest is the last CommonChunk that
only contains the webpack bootstrap code. This is useful for production
use when you want to inline the manifest in your HTML skeleton for long-term caching.
See [issue #1315](https://github.com/webpack/webpack/issues/1315)
or [a blog post](https://medium.com/@matt.krick/a-production-ready-realtime-saas-with-webpack-7b11ba2fa5b0#.p1vvfr3bm)
to learn more.
```js
new AssetsPlugin({includeManifest: 'manifest'})
// assets.json:
// {entries: {manifest: {js: `hashed_manifest.js`, text: 'function(modules)...'}}}
//
// Your html template:
// <script>
// {assets.entries.manifest.text}
// </script>
```
The `includeManifest` option also accepts an array of manifests:
```js
new AssetsPlugin({includeManifest: ['manifest1', 'manifest2']})
// assets.json:
// {entries: {
// manifest1: {js: `hashed_manifest.js`, text: 'function(modules)...'},
// manifest2: {js: `hashed_manifest.js`, text: 'function(modules)...'}
// }}
```
#### `manifestFirst`
Optional. `false` by default.
Orders the assets output so that manifest is the first entry. This is useful for cases where script tags are generated
from the assets json output, and order of import is important.
```js
new AssetsPlugin({manifestFirst: true})
```
#### `path`
Optional. Defaults to the current directory.
Path where to save the created JSON file. Will default to the highest level of the project unless useCompilerPath is specified.
```js
new AssetsPlugin({path: path.join(__dirname, 'app', 'views')})
```
#### `useCompilerPath`
```js
new AssetsPlugin({useCompilerPath: true})
```
Will override the path to use the compiler output path set in your webpack config.
#### `prettyPrint`
Optional. `false` by default.
Whether to format the JSON output for readability.
```js
new AssetsPlugin({prettyPrint: true})
```
#### `processOutput`
Optional. Defaults is JSON stringify function.
Formats the assets output.
```js
new AssetsPlugin({
processOutput: function (assets) {
return 'window.staticMap = ' + JSON.stringify(assets)
}
})
```
#### `update`
Optional. `false` by default.
When set to `true`, the output JSON file will be updated instead of overwritten.
```js
new AssetsPlugin({update: true})
```
#### `metadata`
Inject metadata into the output file. All values will be injected into the key "metadata".
```js
new AssetsPlugin({metadata: {version: 123}})
// Manifest will now contain:
// {
// metadata: {version: 123}
// }
```
#### `includeAllFileTypes`
Optional. `true` by default.
When set false, falls back to the `fileTypes` option array to decide which file types to include in the assets file.
```js
new AssetsPlugin({includeAllFileTypes: false})
```
#### `fileTypes`
Optional. `['js', 'css']` by default.
When set and `includeAllFileTypes` is set false, only assets matching these types will be included in the assets file.
```js
new AssetsPlugin({fileTypes: ['js', 'jpg']})
```
#### `keepInMemory`
Optional. `false` by default.
When set the assets file will only be generated in memory while running `webpack-dev-server` and not written to disk.
```js
new AssetsPlugin({keepInMemory: true})
```
#### `integrity`
Optional. `false` by default.
When set the output from [webpack-subresource-integrity](https://github.com/waysact/webpack-subresource-integrity) is included in the assets file.
Please make sure you have `webpack-subresource-integrity` installed and included in your webpack plugins.
```js
new AssetsPlugin({integrity: true})
```
Output will now look like this:
```json
{
"main": {
"js": "/bundle.js",
"jsIntegrity": "sha256-ANGwtktWN96nvBI/cjekdTvd0Dwf7SciIFTQ2lpTxGc= sha384-Ly439pF3K+J8hnhk1BEcjKnv1R9BApFYVIVJvr64PcgBjdT4N7hfPzQynItHwcaO"
},
"vendors~main": {
"js": "/1.bundle.js",
"jsIntegrity": "sha256-yqNi1hgeAdkXVOORgmVMeX+cbuXikoj6I8qWZjPegsA= sha384-4X75tnsGDwnwL5kBUPsx2ko9DeWy0xM8BcDQdoR185yho+OnxjjPXl2wCdebLWTG"
}
}
```
#### `entrypoints`
Optional. `false` by default.
If the 'entrypoints' option is given, the output will be limited to the entrypoints and the chunks associated with them.
```js
new AssetsPlugin({entrypoints: true})
```
#### `includeFilesWithoutChunk`
Optional. `false` by default.
When set and `entrypoints` is set true, will output any files that are part of the unnamed chunk to an additional unnamed ("") entry.
```js
new AssetsPlugin({includeFilesWithoutChunk: true})
```
#### `includeAuxiliaryAssets`
Optional. `false` by default.
When set, will output any files that are part of the chunk and marked as auxiliary assets.
```js
new AssetsPlugin({includeAuxiliaryAssets: true})
```
#### `includeDynamicImportedAssets`
Optional. `false` by default.
When set, will output any files that are part of the chunk and marked as preloadable or prefechtable child assets via a dynamic import.
See: https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules
```js
new AssetsPlugin({includeDynamicImportedAssets: true})
```
### Using in multi-compiler mode
If you use webpack multi-compiler mode and want your assets written to a single file,
you __must__ use the same instance of the plugin in the different configurations.
For example:
```js
var webpack = require('webpack')
var AssetsPlugin = require('assets-webpack-plugin')
var assetsPluginInstance = new AssetsPlugin()
webpack([
{
entry: {one: 'src/one.js'},
output: {path: 'build', filename: 'one-bundle.js'},
plugins: [assetsPluginInstance]
},
{
entry: {two:'src/two.js'},
output: {path: 'build', filename: 'two-bundle.js'},
plugins: [assetsPluginInstance]
}
])
```
### Using this with Rails
You can use this with Rails to find the bundled Webpack assets via Sprockets.
In `ApplicationController` you might have:
```ruby
def script_for(bundle)
path = Rails.root.join('app', 'views', 'webpack-assets.json') # This is the file generated by the plug-in
file = File.read(path)
json = JSON.parse(file)
json[bundle]['js']
end
```
Then in the actions:
```ruby
def show
@script = script_for('clients') # this will retrieve the bundle named 'clients'
end
```
And finally in the views:
```erb
<div id="app">
<script src="<%= @script %>"></script>
</div>
```
### Using this with ASP.NET Core
You can use this with ASP.NET Core via the [WebpackTag](https://d.sb/webpacktag) library.
## Test
```sh
npm test
```