Skip to content

Commit d68143c

Browse files
author
seeliang
committed
feat/add js source mapping
alt + r for dev tool update webpack/webpack#2478
1 parent 7f71b4c commit d68143c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import React from 'react';
22
import {render} from 'react-dom';
33

44
class Root extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
this.click = this.click.bind(this);
8+
}
9+
10+
click() {
11+
alert('click this');
12+
}
13+
514
render() {
615
return (
716
<div>
817
<h1> Hello world</h1>
918
<input type="checkbox"/>
19+
<button onClick={this.click}> try this</button>
1020
</div>
1121
);
1222
}

webpack.dev.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const base = require('./webpack.base.js'),
2+
webpack = require('webpack'),
23
dev = {
34
module: {
45
loaders: [{
@@ -10,7 +11,13 @@ const base = require('./webpack.base.js'),
1011
presets: [ 'es2015', 'react', 'react-hmre' ]
1112
}
1213
}]
13-
}
14+
},
15+
plugins: [
16+
new webpack.SourceMapDevToolPlugin({
17+
filename: '[name].js.map',
18+
exclude: ['vendor.js']
19+
})
20+
]
1421
};
1522

1623
module.exports = Object.assign(base, dev);

0 commit comments

Comments
 (0)