Skip to content

Commit

Permalink
Merge pull request #136 from danybeltran/feat-prod-build
Browse files Browse the repository at this point in the history
adds production build
  • Loading branch information
danybeltran authored Jan 25, 2023
2 parents 1954122 + a651654 commit 65c4e32
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ babel.config.js
jest.config.js
tsconfig.json
yarn.lock
webpack.config.js
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ Or
yarn add http-react
```

For production apps

```html
<!-- Add React and ReactDOM -->
<script
src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"
crossorigin
></script>

<script
src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"
crossorigin
></script>

<!-- Add Http React -->
<script src="https://unpkg.com/http-react/dist/browser/http-react.min.js"></script>
```



[Getting started](https://http-react.netlify.app/docs)


9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "http-react",
"version": "2.6.7",
"version": "2.6.8",
"description": "React hooks for data fetching",
"main": "dist/index.js",
"scripts": {
"test": "jest",
"compile": "tsc"
"compile": "tsc && webpack --mode production"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,7 +47,10 @@
"react-dom": ">=16.13.1",
"react-test-renderer": "^17.0.2",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
"ts-loader": "^9.4.2",
"typescript": "^4.5.5",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
},
"peerDependencies": {
"react": ">=16.13.1"
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"target": "ES5",
"outDir": "./dist",
"module": "CommonJS",
"target": "es5",
"lib": ["es6", "dom", "es2019"],
"sourceMap": false,
"allowJs": true,
"jsx": "react",
"strict": false,
"moduleResolution": "node",
"esModuleInterop": true,
"rootDir": "src",
Expand Down
26 changes: 26 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const webpack = require('webpack')
const path = require('path')

/**
* @type { import("webpack-cli").ConfigOptions }
*/
module.exports = {
entry: './dist/index.js',

resolve: {
extensions: ['.js'],
alias: {
HttpReact: path.resolve(__dirname, './dist/index.js')
}
},
externals: {
react: 'React'
},
output: {
clean: true,
path: path.resolve(__dirname, 'dist/browser'),
filename: 'http-react.min.js',
library: 'HttpReact',
libraryTarget: 'window'
}
}

0 comments on commit 65c4e32

Please sign in to comment.