182
rated 0 times
[
185]
[
3]
/ answers: 1 / hits: 37869
/ 9 Years ago, tue, november 3, 2015, 12:00:00
webpack.config.js
module.exports = {
context: __dirname + /app,
entry: {
javascript: ./app.js,
html: ./index.html,
},
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
filename: app.js,
path: __dirname + /dist,
},
module: {
loaders: [
{
test: /.jsx?$/,
exclude: /node_modules/,
loader: babel-loader,
},
{
test: /.html$/,
loader: file?name=[name].[ext],
},
],
},
}
package.json
{
name: react-webpack-project,
version: 1.0.0,
description: ,
main: index.js,
scripts: {
test: echo Error: no test specified && exit 1
},
author: ,
license: ISC,
devDependencies: {
babel: ^6.0.15,
babel-core: ^6.0.20,
babel-loader: ^6.0.1,
file-loader: ^0.8.4,
webpack: ^1.12.2
},
dependencies: {
react: ^0.14.2
}
}
app/app.js
import React from react;
import Greeting from ./greeting;
React.render(
<Greeting name=World/>,
document.body
);
I have seen the exact same questions after searching around, but none of the answers seemed to apply to me. I am getting the following error when running webpack
:
ERROR in ./app.js
Module build failed: SyntaxError: path/to/project/react-webpack-project/app/app.js: Unexpected token (5:2)
React.render(
<Greeting name=World/>,
document.body
);
I am not sure why I am getting this error still. I am guessing it has something to do with my webpack.config.js file, but not 100% what the problem is.
More From » node.js