{"_id":"dj-add-asset-html-webpack-plugin","_rev":"27583397","name":"dj-add-asset-html-webpack-plugin","description":"daojia use add-asset-html-webpack-plugin","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"zhangjunchao","email":"504797138@qq.com"}],"time":{"modified":"2018-12-24T05:58:35.000Z","created":"2018-12-24T04:04:36.941Z","1.0.1":"2018-12-24T05:58:22.117Z","1.0.0":"2018-12-24T04:04:36.941Z"},"users":{},"author":"","versions":{"1.0.1":{"name":"dj-add-asset-html-webpack-plugin","version":"1.0.1","description":"daojia use add-asset-html-webpack-plugin","main":"lib/index.js","directories":{"lib":"lib"},"dependencies":{"globby":"^8.0.0","micromatch":"^3.1.3","p-each-series":"^1.0.0"},"scripts":{"test":"jest"},"author":"","license":"ISC","_id":"dj-add-asset-html-webpack-plugin@1.0.1","_npmVersion":"5.5.1","_nodeVersion":"9.0.0","_npmUser":{"name":"zhangjunchao","email":"504797138@qq.com"},"dist":{"shasum":"20c820c69fdf21d01c3ca3f63afd9869a7842752","size":5486,"noattachment":false,"tarball":"https://registry.npm.taobao.org/dj-add-asset-html-webpack-plugin/download/dj-add-asset-html-webpack-plugin-1.0.1.tgz"},"maintainers":[{"name":"zhangjunchao","email":"504797138@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dj-add-asset-html-webpack-plugin_1.0.1_1545631102018_0.6607417814111332"},"_hasShrinkwrap":false,"publish_time":1545631102117,"_cnpm_publish_time":1545631102117},"1.0.0":{"name":"dj-add-asset-html-webpack-plugin","version":"1.0.0","description":"daojia use add-asset-html-webpack-plugin","main":"lib/index.js","directories":{"lib":"lib"},"scripts":{"test":"jest"},"author":"","license":"ISC","_id":"dj-add-asset-html-webpack-plugin@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.0.0","_npmUser":{"name":"zhangjunchao","email":"504797138@qq.com"},"dist":{"shasum":"64239f98eca332b865d7d709c0af35146a7992bd","size":5452,"noattachment":false,"tarball":"https://registry.npm.taobao.org/dj-add-asset-html-webpack-plugin/download/dj-add-asset-html-webpack-plugin-1.0.0.tgz"},"maintainers":[{"name":"zhangjunchao","email":"504797138@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dj-add-asset-html-webpack-plugin_1.0.0_1545624276807_0.6536420028485552"},"_hasShrinkwrap":false,"publish_time":1545624276941,"_cnpm_publish_time":1545624276941}},"readme":"# add-asset-html-webpack-plugin\n\n> Add a JavaScript or CSS asset to the HTML generated by `html-webpack-plugin`\n\n[![NPM Version][npm-image]][npm-url]\n[![Linux & Mac Build Status][travis-image]][travis-url]\n[![Windows Build Status][appveyor-image]][appveyor-url]\n[![Code Coverage branch][codecov-image]][codecov-url]\n\n[![Dependency Status][david-image]][david-url]\n[![Dev Dependency Status][david-dev-image]][david-dev-url]\n[![Peer Dependency Status][david-peer-image]][david-peer-url]\n[![Greenkeeper Dependency Status][greenkeeper-image]][greenkeeper-url]\n\n## Installation\n\nInstall the plugin with `npm`:\n\n```sh\n$ npm i add-asset-html-webpack-plugin -D\n```\n\nNOTE: This plugin requires `html-webpack-plugin@^2.10.0`.\n\n## Migrating to webpack 4+\n\nAfter webpack 4+, it is required to apply `AddAssetHtmlPlugin` after\n`HtmlWebpackPlugin` to register `html-webpack-plugin-before-html-generation`\nhook which is used inside first, while previous versions of webpack do not care\nabout it.\n\n## Basic Usage\n\nThe plugin will add the given JS or CSS file to the files Webpack knows about,\nand put it into the list of assets `html-webpack-plugin` injects into the\ngenerated html. Add the plugin the your config, providing it a filepath:\n\n```js\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');\nconst webpackConfig = {\n entry: 'index.js',\n output: {\n path: 'dist',\n filename: 'index_bundle.js',\n },\n plugins: [\n new HtmlWebpackPlugin(),\n new AddAssetHtmlPlugin({ filepath: require.resolve('./some-file') }),\n ],\n};\n```\n\nThis will add a script tag to the HTML generated by `html-webpack-plugin`, and\nlook like:\n\n```html\n\n\n \n \n Webpack App\n \n \n \n \n \n\n```\n\nNOTE: You can also pass an array of assets to be added. Same API as mentioned\nbelow, just pass multiple objects as an array.\n\n```js\nnew AddAssetHtmlPlugin([\n { filepath: require.resolve('./some-file') },\n { filepath: require.resolve('./some-other-file') },\n // Glob to match all of the dll file\n { filepath: require.resolve('./**/*.dll.js') },\n]);\n```\n\n## Options\n\nOptions are passed to the plugin during instantiation.\n\n```js\nnew AddAssetHtmlPlugin({ filepath: require.resolve('./some-file') });\n```\n\n#### `filepath`\n\nType: `string|Glob`, mandatory\n\nThe absolute path of the file you want to add to the compilation, and resulting\nHTML file. Also support globby string.\n\n#### `files`\n\nType: `string|Array`, default `[]\n\nFiles that the assets will be added to.\n\nBy default the assets will be included in all files. If files are defined, the\nassets will only be included in specified file globs.\n\n#### `hash`\n\nType: `boolean`, default: `false`\n\nIf `true`, will append a unique hash of the file to the filename. This is useful\nfor cache busting.\n\n#### `includeRelatedFiles`\n\nType: `boolean`, default: `true`\n\nIf `true`, will add `filepath + '.*'` to the compilation as well. E.g\n`filepath.map` and `filepath.gz`.\n\n#### `outputPath`\n\nType: `string`\n\nIf set, will be used as the output directory of the file.\n\n#### `publicPath`\n\nType: `string`\n\nIf set, will be used as the public path of the script or link tag.\n\n#### `typeOfAsset`\n\nType: `string`, default: `js`\n\nCan be set to `css` to create a `link`-tag instead of a `script`-tag.\n\n#### `attributes`\n\nType: `object`, default: `{}`\n\nExtra attributes to be added to the generated tag. Useful to for instance add\n`nomodule` to a polyfill script. The `attributes` object uses the key as the\nname of the attribute, and the value as the value of it. If value is simply\n`true` no value will be added.\n\nAn example of this is included in the repository.\n\nCurrently only supports script tags.\n\n## Examples\n\nWhen adding assets, it's added to the start of the array, so when\n`html-webpack-plugin` injects the assets, it's before other assets. If you\ndepend on some order for the assets beyond that, and ordering the plugins\ndoesn't cut it, you'll have to create a custom template and add the tags\nyourself.\n\n### Add a DLL file from `webpack.DllPlugin`\n\nNote: Remember to build the DLL file in a separate build.\n\nSee [example](example/dll/) for an example of how to set it up. You can run it\nby cloning this repo, running `yarn` followed by `yarn run example`.\n\n#### Webpack config\n\n```js\nconst path = require('path');\nconst webpack = require('webpack');\nconst webpackConfig = {\n entry: {\n vendor: ['react', 'redux', 'react-router'],\n },\n devtool: '#source-map',\n output: {\n path: path.join(__dirname, 'build'),\n filename: '[name].dll.js',\n library: '[name]_[hash]',\n },\n plugins: [\n new webpack.DllPlugin({\n path: path.join(__dirname, 'build', '[name]-manifest.json'),\n name: '[name]_[hash]',\n }),\n ],\n};\n```\n\nYour main build:\n\n```js\nconst path = require('path');\nconst webpack = require('webpack');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');\nconst webpackConfig = {\n entry: 'index.js',\n output: {\n path: 'dist',\n filename: 'index_bundle.js',\n },\n plugins: [\n new webpack.DllReferencePlugin({\n context: path.join(__dirname),\n manifest: require('./build/vendor-manifest.json'),\n }),\n new HtmlWebpackPlugin(),\n new AddAssetHtmlPlugin({\n filepath: path.resolve(__dirname, './build/*.dll.js'),\n }),\n ],\n};\n```\n\n### Add a polyfill file you have locally\n\nSee [example](example/polyfill/) for an example of how to use it. You can run it\nby cloning this repo, running `yarn` followed by `yarn run example`.\n\n#### Webpack config\n\n```js\nconst path = require('path');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst AddAssetHtmlPlugin = require('../../');\n\nconst webpackConfig = {\n entry: 'entry.js',\n devtool: '#source-map',\n mode: 'development',\n output: {\n path: 'dist',\n filename: 'index_bundle.js',\n },\n plugins: [\n new HtmlWebpackPlugin(),\n new AddAssetHtmlPlugin({\n filepath: path.resolve(__dirname, './polyfill.js'),\n attributes: {\n nomodule: true,\n },\n }),\n ],\n};\n```\n\n[npm-url]: https://npmjs.org/package/add-asset-html-webpack-plugin\n[npm-image]: https://img.shields.io/npm/v/add-asset-html-webpack-plugin.svg\n[travis-url]: https://travis-ci.org/SimenB/add-asset-html-webpack-plugin\n[travis-image]:\n https://img.shields.io/travis/SimenB/add-asset-html-webpack-plugin/master.svg\n[appveyor-url]:\n https://ci.appveyor.com/project/SimenB/add-asset-html-webpack-plugin\n[appveyor-image]:\n https://ci.appveyor.com/api/projects/status/dim5hcl49h3pi332/branch/master?svg=true\n[codecov-url]: https://codecov.io/gh/SimenB/add-asset-html-webpack-plugin\n[codecov-image]:\n https://img.shields.io/codecov/c/github/SimenB/add-asset-html-webpack-plugin/master.svg\n[david-url]: https://david-dm.org/SimenB/add-asset-html-webpack-plugin\n[david-image]:\n https://img.shields.io/david/SimenB/add-asset-html-webpack-plugin.svg\n[david-dev-url]:\n https://david-dm.org/SimenB/add-asset-html-webpack-plugin?type=dev\n[david-dev-image]:\n https://img.shields.io/david/dev/SimenB/add-asset-html-webpack-plugin.svg\n[david-peer-url]:\n https://david-dm.org/SimenB/add-asset-html-webpack-plugin?type=peer\n[david-peer-image]:\n https://img.shields.io/david/peer/SimenB/add-asset-html-webpack-plugin.svg\n[greenkeeper-url]: https://greenkeeper.io/\n[greenkeeper-image]:\n https://badges.greenkeeper.io/SimenB/add-asset-html-webpack-plugin.svg\n","_attachments":{},"license":"ISC"}