public-webpack-plugin
v0.1.0
Published
webpack plugin that emits a JSON file with public paths
Downloads
7
Readme
PublicWebpackPlugin
A companion plugin for public-loader, it emits a JSON file with paths to included public files.
It's like assets-webpack-plugin but for static assets.
Installation
Install public-loader and file-loader:
npm install public-loader file-loader --save-dev
Install the plugin:
npm install public-webpack-plugin --save-dev
Example
In a webpack config:
var path = require('path')
var PublicWebpackPlugin = require('public-webpack-plugin')
// ...
var distPath = path.join(process.cwd(), 'dist')
module.exports = {
// ...
output: {
path: distPath,
publicPath: '/',
// ...
},
plugins: [new PublicWebpackPlugin({
path: path.join(distPath, 'public.json')
})]
}
In an entry:
require.context('!!public!./assets', true, /.+/)
// ...
Run webpack to build entries:
webpack
cat dist/public.json
:
{
"/Users/koss/src/date-fns/date-fns.org/ui/static/img/favicon.png": "/e09ef13032827f865ef8004c185277f7.png"
}
License
MIT