Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit eb4f8bd

Browse files
author
Alan Shaw
authored
docs: update bundle-webpack example (#945)
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent e69aca1 commit eb4f8bd

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

examples/bundle-webpack/.babelrc

-3
This file was deleted.

examples/bundle-webpack/package.json

+16-8
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
"license": "MIT",
1010
"keywords": [],
1111
"devDependencies": {
12-
"babel-core": "^5.4.7",
13-
"babel-loader": "^5.1.2",
12+
"@babel/core": "^7.2.2",
13+
"@babel/preset-env": "^7.3.1",
14+
"@babel/preset-react": "^7.0.0",
15+
"babel-loader": "^8.0.5",
1416
"ipfs-http-client": "../../",
15-
"json-loader": "~0.5.3",
16-
"react": "~0.13.0",
17-
"react-hot-loader": "^1.3.0",
18-
"webpack": "^1.9.6",
19-
"webpack-dev-server": "^1.8.2"
20-
}
17+
"react": "^16.8.1",
18+
"react-dom": "^16.8.1",
19+
"react-hot-loader": "^4.6.5",
20+
"webpack": "^4.29.3",
21+
"webpack-dev-server": "^3.1.14"
22+
},
23+
"browserslist": [
24+
">1%",
25+
"not dead",
26+
"not ie <= 11",
27+
"not op_mini all"
28+
]
2129
}

examples/bundle-webpack/src/App.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ class App extends React.Component {
2929
if (err) throw err
3030
const hash = res[0].hash
3131
this.setState({added_file_hash: hash})
32-
ipfs.cat(hash, (err, res) => {
32+
ipfs.cat(hash, (err, data) => {
3333
if (err) throw err
34-
let data = ''
35-
res.on('data', (d) => {
36-
data = data + d
37-
})
38-
res.on('end', () => {
39-
this.setState({added_file_contents: data})
40-
})
34+
this.setState({added_file_contents: data.toString()})
4135
})
4236
})
4337
}

examples/bundle-webpack/src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22
const React = require('react')
3+
const ReactDOM = require('react-dom')
34
const App = require('./App')
45

5-
React.render(<App />, document.getElementById('root'))
6+
ReactDOM.render(<App />, document.getElementById('root'))

examples/bundle-webpack/webpack.config.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict'
22

3-
var path = require('path')
4-
var webpack = require('webpack')
3+
const path = require('path')
4+
const webpack = require('webpack')
55

66
module.exports = {
7+
mode: 'production',
78
devtool: 'eval',
89
entry: [
910
'webpack-dev-server/client?http://localhost:3000',
@@ -19,11 +20,18 @@ module.exports = {
1920
new webpack.HotModuleReplacementPlugin()
2021
],
2122
module: {
22-
loaders: [{
23-
test: /\.js$/,
24-
loaders: ['react-hot', 'babel'],
25-
include: path.join(__dirname, 'src')
26-
}, { test: /\.json$/, loader: 'json-loader' }]
23+
rules: [
24+
{
25+
test: /\.js$/,
26+
exclude: /node_modules/,
27+
use: {
28+
loader: 'babel-loader',
29+
options: {
30+
presets: ['@babel/preset-env', '@babel/preset-react']
31+
}
32+
}
33+
}
34+
]
2735
},
2836
node: {
2937
fs: 'empty',

0 commit comments

Comments
 (0)