1. 程式人生 > >webpack配置報錯

webpack配置報錯

錯誤:

ERROR in ./react/index.js

Module parse failed: Unexpected token (8:12)
You may need an appropriate loader to handle this file type.
|
|         return(
|             <h1>123</h1>
|         )

|     }

webpack.react.config.js(配置檔案)

{ test:/\.js$/, loader:'babel-loader', exclude:/node_modules
/, include:path.resolve(__dirname, '/react/'), } ,

報錯原因:

在include中寫檔名稱的時候不用寫"/"

正確的:

include:path.resolve(__dirname, 'react'),