srn / react-webpack-boilerplate

Simple production ready boilerplate for React, Webpack (using Babel 6, SASS and React hot reloading), tests (using Jest) and coverage.
MIT License
377 stars 103 forks source link

Errors when running npm start #21

Open chinds185a opened 8 years ago

chinds185a commented 8 years ago

Hi, I have run through the npm install which succeeded then when I ran npm start i was presented with the error see in the attached image. The server did start but the browser console also complains that it cannot find ./client/main.jsx

I am running node 6.5 and npm 3.10.3

screen shot 2016-09-10 at 12 25 52

Chrome console error:

screen shot 2016-09-10 at 12 29 32

jbultmann commented 8 years ago

Hi,

i encountered the same problem. I figured that the precompiling was not able to recognize the JSX Syntax. To fix this i explicitly defined all the babel plugins specified in the package.json inside the webpack loader.

In webpack.config.development.js change

config.module.loaders = config.module.loaders.concat([
  {test: /\.jsx?$/, loaders: [ 'react-hot', 'babel'], exclude: /node_modules/}
]);

to

config.module.loaders = config.module.loaders.concat([
  {
      test: /\.jsx?$/,
      loaders: [ 'react-hot', 'babel?presets[]=es2015&presets[]=react&presets[]=stage-0'],
      exclude: /node_modules/
  }
]);

same in webpack.config.production.js just without the hotloading.

config.module.loaders = config.module.loaders.concat([
  {test: /\.jsx?$/, loaders: [ 'babel'], exclude: /node_modules/}
]);

to

config.module.loaders = config.module.loaders.concat([
  {
      test: /\.jsx?$/,
      loaders: [ 'babel?presets[]=es2015&presets[]=react&presets[]=stage-0'],
      exclude: /node_modules/
  }
]);

I am not sure if babel will use a .babelrc file with webpack as I never tested it. If so this could also be resolved with a single .babelrc

{
   "plugins": ["es-2015", "react", "stage-0"]
}

EDIT: Just tested the .babelrc Version. It Works and is IMO the cleaner method

elliotrock commented 7 years ago

@jbultmann What was the setup for the .babelrc version? Thanks

elliotrock commented 7 years ago

Seems too many errors to make this a usable boiler-plate next!