-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for public/ folder (#703)
- Loading branch information
Showing
14 changed files
with
202 additions
and
122 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/react-scripts/scripts/utils/InterpolateHtmlPlugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// @remove-on-eject-begin | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
// @remove-on-eject-end | ||
|
||
// This Webpack plugin lets us interpolate custom variables into `index.html`. | ||
// Usage: `new InterpolateHtmlPlugin({ 'MY_VARIABLE': 42 })` | ||
// Then, you can use %MY_VARIABLE% in your `index.html`. | ||
|
||
// It works in tandem with HtmlWebpackPlugin. | ||
// Learn more about creating plugins like this: | ||
// https://github.com/ampedandwired/html-webpack-plugin#events | ||
|
||
'use strict'; | ||
|
||
class InterpolateHtmlPlugin { | ||
constructor(replacements) { | ||
this.replacements = replacements; | ||
} | ||
|
||
apply(compiler) { | ||
compiler.plugin('compilation', compilation => { | ||
compilation.plugin('html-webpack-plugin-before-html-processing', | ||
(data, callback) => { | ||
// Run HTML through a series of user-specified string replacements. | ||
Object.keys(this.replacements).forEach(key => { | ||
const value = this.replacements[key]; | ||
data.html = data.html.replace('%' + key + '%', value); | ||
}); | ||
callback(null, data); | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = InterpolateHtmlPlugin; |
Oops, something went wrong.