Maison > Questions et réponses > le corps du texte
webpack.config.js :
let webpack = require('webpack');
let path = require('path');
module.exports = {
context:__dirname + '/src',
entry:"./js/index.js",
module:{
loaders:[
{
test: /\.js?$/,
exclude: /node_modules/,
loader:'babel-loader',
query:{
presets:['es2015','react']
}
}
]
},
output:{
path:__dirname + "/src",
filename:"bundle.js"
}
};
package.json :
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"antd": "^2.1.0",
"babel": "^5.8.23",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.4"
}
}
我想大声告诉你2017-05-19 10:33:05
La configuration du webpack
est correcte. L'erreur devrait être babel
query
Il y a un problème là-bas. webpack
配置没问题。报错应该是 babel
query
那里有问题。
第一种解决方法:presets:['es2015','react']map(require.resolve)
第一种没解决,就把query
删掉,在根目录下新建.babelrc
把 query
这个json
对象放进去
第二种也没解决的话,升级一下babel
presets :['es2015','react']map(require.resolve)
query
, créez un nouveau .babelrc
dans le répertoire racine et remplacez query
Mettez-y l'objet json
#🎜🎜##🎜🎜#
babel
et répétez les étapes ci-dessus. #🎜🎜##🎜🎜#
#🎜🎜#