webpack时候出错

来源:5-3 webpack热加载配置(中)

qq_谜离_03319966

2017-08-23

http://szimg.mukewang.com/599d7b89000113f109950459.jpg问题补充(选填):请详细描述你的问题,贴出相关代码或截图,并告知你的操作步骤

写回答

2回答

qq_谜离_03319966

提问者

2017-08-24

index.js↓

var React = require('react');
var ReactDOM = require('react-dom');

ReactDOM.render(
  <h1>Hello World!</h1>,
  document.getElementById('example')
);

webpack.config.js↓

var webpack = require('webpack');
var path = require('path');
module.exports={
  context: __dirname+'/src',
  entry:"./js/index.js",
  mondule:{
     loaders:[{
        test:/\.js?$/,
        exclude:/(node_modules)/,
        loader:'babel-loader',
        query:{
           presets:['react','es2015']
        }
     }]
  },
  output: {
     path: __dirname+"/src/",
     filename: "bundle.js"
  }
};

package.json↓

{
 "name": "react01",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "scripts": {
   "test": "echo \"Error: no test specified\" && exit 1"
 },
 "author": "",
 "license": "ISC",
 "dependencies": {
   "babel-preset-es2015": "^6.24.1",
   "babel-preset-react": "^6.24.1",
   "babelify": "^7.3.0",
   "create-react-app": "^1.4.0",
   "react": "^15.6.1",
   "react-dom": "^15.6.1",
   "webpack": "^3.5.5",
   "webpack-dev-server": "^2.7.1"
 }
}

代码我是找着敲的 不过 编辑器我用的是webstorm

在命令行执行webpack的时候 报错

下面是报错信息

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration has an unknown property 'mondule'. These properties are valid:

   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }

   For typos: please correct them.

   For loader options: webpack 2 no longer allows custom properties in configuration.

     Loaders should be updated to allow passing options via loader options in module.rules.

     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:

     plugins: [

       new webpack.LoaderOptionsPlugin({

         // test: /\.xxx$/, // may apply this only for some modules

         options: {

           mondule: ...

         }

       })

     ]


0
0

Parry

2017-08-23

你这样提问我猜不出你的问题,请提供部分代码。

0
1
qq_谜离_03319966
问题已经补充
2017-08-24
共1条回复

结合基础与实战学习React.js 独立开发新闻头条平台

轻松入门 React 开发,React Router 4 与 Webpack 2 完美升级项目

2768 学习 · 2126 问题

查看课程