143
rated 0 times
[
146]
[
3]
/ answers: 1 / hits: 18379
/ 8 Years ago, sun, november 27, 2016, 12:00:00
I am just new to webpack and react , just going through the docs and created a example to work. Unfortunately i got stuck and not able to proceed . Th problem is the bundled file is not generated.
The files i created is
package.json
{
name: rohith,
version: 1.0.0,
description: ,
main: index.js,
scripts: {
start: webpack-dev-server
},
author: ,
license: ISC,
dependencies: {
react: ^15.4.1,
react-dom: ^15.4.1,
webpack: ^1.13.3,
webpack-dev-server: ^1.16.2
}
}
webpack.config.js
module.export = {
entry : './main.js',
output : {
path : './',
filename : 'index.js'
},
devServer : {
inline : true,
port : 3333
},
module : {
loaders : [
{
test : /.js$/,
exclude : /node_modules/,
loader : 'babel',
query : {
presets : ['es2015','react']
}
}
]
}
}
App.js
import React from 'react';
class App extends React.Component {
render(){
return <div>Hello</div>
}
}
export default App
main.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />,document.getElementById('app'));
index.html
<!DOCTYPE html>
<html lang = en>
<head>
<meta charset = UTF-8>
<title>Setup</title>
</head>
<body>
<div id = app></div>
<script src =index.js></script>
</body>
</html>
I am getting that bundle is valid, but no index.js is generated.
can't run in localhost 3333
Thanks,
More From » reactjs