Skip to content

Commit 55a8d4c

Browse files
lukythjarlef
authored andcommitted
Create asset filenames mapping on the build output (facebook#891)
* Create asset filenames mapping on the build output I use danethurber/webpack-manifest-plugin on Webpack production configuration to create a file named `asset-manifest.json` which contain a mapping of all asset filenames to their corresponding output file. `asset-manifest.json` will be located at the root of output folder. This'll resolve facebook#600 * Add an explanation for ManifestPlugin * Make webpack-manifest-plugin's version exact
1 parent d274675 commit 55a8d4c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/react-scripts/config/webpack.config.prod.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var autoprefixer = require('autoprefixer');
1414
var webpack = require('webpack');
1515
var HtmlWebpackPlugin = require('html-webpack-plugin');
1616
var ExtractTextPlugin = require('extract-text-webpack-plugin');
17+
var ManifestPlugin = require('webpack-manifest-plugin');
1718
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1819
var url = require('url');
1920
var paths = require('./paths');
@@ -250,7 +251,13 @@ module.exports = {
250251
}
251252
}),
252253
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
253-
new ExtractTextPlugin('static/css/[name].[contenthash:8].css')
254+
new ExtractTextPlugin('static/css/[name].[contenthash:8].css'),
255+
// Generate a manifest file which contains a mapping of all asset filenames
256+
// to their corresponding output file so that tools can pick it up without
257+
// having to parse `index.html`.
258+
new ManifestPlugin({
259+
fileName: 'asset-manifest.json'
260+
})
254261
],
255262
// Some libraries import Node modules but don't use them in the browser.
256263
// Tell Webpack to provide empty mocks for them so importing them works.

packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"url-loader": "0.5.7",
6666
"webpack": "1.13.2",
6767
"webpack-dev-server": "1.16.1",
68+
"webpack-manifest-plugin": "1.0.1",
6869
"whatwg-fetch": "1.0.0"
6970
},
7071
"devDependencies": {

0 commit comments

Comments
 (0)