Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
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

 Answers
3

In webpack.config.js, use module.exports instead of module.export. See Output filename not configured Error in Webpack
Also be noticed that your package.json lacks some dependencies. Here is the updated package.json that works:



{
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
},
devDependencies: {
babel: ^6.5.2,
babel-core: ^6.18.2,
babel-loader: ^6.2.8,
babel-preset-es2015: ^6.18.0,
babel-preset-react: ^6.16.0
}
}

[#59910] Wednesday, November 23, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maya

Total Points: 418
Total Questions: 116
Total Answers: 112

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
maya questions
Sun, Jul 4, 21, 00:00, 3 Years ago
Tue, Dec 22, 20, 00:00, 4 Years ago
Fri, Nov 6, 20, 00:00, 4 Years ago
Wed, Jul 29, 20, 00:00, 4 Years ago
Tue, Apr 21, 20, 00:00, 4 Years ago
;