mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-28 09:25:42 +08:00
Make all react app vars accessible in index.html (#1440)
* Make all vars accessiable in index.html * Fix wrong env provieded to DefinePlugin * Separate results from getClientEnvironment * The `string` should be object instead of string * Fix accessing wrong field * Changed variables naming to `raw` and `stringified` * Remove trailing commas
This commit is contained in:
@@ -198,12 +198,11 @@ module.exports = {
|
||||
];
|
||||
},
|
||||
plugins: [
|
||||
// Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
|
||||
// Makes some environment variables available in index.html.
|
||||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
// In development, this will be an empty string.
|
||||
new InterpolateHtmlPlugin({
|
||||
PUBLIC_URL: publicUrl
|
||||
}),
|
||||
new InterpolateHtmlPlugin(env.raw),
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
@@ -211,7 +210,7 @@ module.exports = {
|
||||
}),
|
||||
// Makes some environment variables available to the JS code, for example:
|
||||
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
|
||||
new webpack.DefinePlugin(env),
|
||||
new webpack.DefinePlugin(env.stringified),
|
||||
// This is necessary to emit hot updates (currently CSS only):
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
// Watcher doesn't work well if you mistype casing in a path so we use
|
||||
|
||||
Reference in New Issue
Block a user