我知道这个问题很普遍,但最好的部分是因人而异
我的档案: Webpack.config.js
var path = require('path');
var webpack = require('webpack');
const Files = {
input: path.resolve(__dirname,'src/app'),
output: path.resolve(__dirname,'output')
}
console.log(Files.input);
var config = {
entry: Files.input,
output: {
path: Files.output,
filename: 'index.js',
},
devServer: {
inline: true,
port: 9009
},
resolve: { modulesDirectories: ['node_modules', 'src'], extensions: ['','.js','.jsx'] },
stats: {
colors: true,
modules: true,
reasons: true,
errorDetails: true
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}]
}
}
module.exports = config;
的package.json
{
"name": "reactapp",
"version": "1.0.0",
"description": "",
"main": "output/index.js",
"scripts": {
"start": "webpack-dev-server --hot"
},
"author": "batman",
"license": "AMIGOS",
"dependencies": {
"babel-cli": "^6.0.0",
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.2"
}
}
我已经在我的app文件夹中保存了package.json,并使用了虚拟json {"name":"hello"}
作为开发者之一的建议的一部分。我已经尝试了我附近的所有可能情况,但都是徒劳的。
请详细说明一下。
更新: 从!bharath到bharath的文件夹更改错误减少到1.
答案 0 :(得分:1)
const Files = {
// you need to specify the file name as well as webpack entry
input: path.resolve(__dirname,'src/app/main.js'),
output: path.resolve(__dirname,'output')
}