Skip to content

Commit c244013

Browse files
author
chenghan
committed
Initial Commit
0 parents  commit c244013

File tree

7 files changed

+870
-0
lines changed

7 files changed

+870
-0
lines changed

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"eslintIntegration": true,
5+
"semi": false,
6+
"singleQuote": true
7+
}

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Mahmoud Abdulazim
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Rewire create-react-app to override html-webpack-plugin in your project
2+
3+
Let you to override [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) options
4+
5+
## Install
6+
7+
```bash
8+
$ yarn add react-app-rewired react-app-rewire-aliases -D
9+
$ npm install react-app-rewired react-app-rewire-aliases --save-dev
10+
```
11+
12+
## Usage
13+
14+
[Rewire your app](https://github.com/timarney/react-app-rewired#how-to-rewire-your-create-react-app-project) than modify `config-overrides.js`
15+
16+
```js
17+
const rewireHtmlWebpackPlugin = require('react-app-rewire-html-webpack-plugin')
18+
19+
module.exports = function override(config, env) {
20+
const overrideConfig = {}
21+
config = rewireHtmlWebpackPlugin(config, env, overrideConfig)
22+
return config;
23+
}
24+
25+
```

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const deepMerge = require('deepmerge')
2+
3+
/**
4+
* @param {object} config
5+
* @param {string} env
6+
* @param {object} htmlWebpackPluginOptions
7+
*/
8+
function rewireHtmlWebpackPlugin(config, env, htmlWebpackPluginOptions = {}) {
9+
const htmlWebpackPlugin = config.plugins.find(
10+
plugin => plugin.constructor.name === 'HtmlWebpackPlugin'
11+
)
12+
13+
if (!htmlWebpackPlugin) {
14+
throw new Error("Can't find HtmlWebpackPlugin")
15+
}
16+
17+
htmlWebpackPlugin.options = deepMerge(
18+
htmlWebpackPlugin.options,
19+
htmlWebpackPluginOptions
20+
)
21+
22+
return config
23+
}
24+
25+
module.exports = rewireHtmlWebpackPlugin

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "react-app-rewire-html-webpack-plugin",
3+
"version": "1.0.1",
4+
"description": "Let you override html-webpack-plugin options in react-scripts",
5+
"main": "index.js",
6+
"scripts": {
7+
"precommit": "lint-staged"
8+
},
9+
"keywords": [
10+
"create-react-app",
11+
"react-scripts",
12+
"react-app-rewired",
13+
"react-app-rewire",
14+
"html-webpack-plugin"
15+
],
16+
"license": "MIT",
17+
"author": "Cheng Han<[email protected]>",
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/Cheng0639/react-app-rewire-html-webpack-plugin.git"
21+
},
22+
"bugs": {
23+
"url": "https://github.com/Cheng0639/react-app-rewire-html-webpack-plugin/issues"
24+
},
25+
"homepage": "https://github.com/Cheng0639/react-app-rewire-html-webpack-plugin#readme",
26+
"dependencies": {
27+
"deepmerge": "^4.2.2"
28+
},
29+
"devDependencies": {
30+
"husky": "^0.14.3",
31+
"lint-staged": "^4.2.1",
32+
"prettier": "^1.7.0"
33+
},
34+
"peerDependencies": {
35+
"react-app-rewired": "^2.1.5"
36+
},
37+
"lint-staged": {
38+
"*.js": ["prettier --write", "git add"],
39+
"*.json": ["prettier --parser json --write", "git add"]
40+
}
41+
}

0 commit comments

Comments
 (0)