【问题标题】:Error in MultiMain could not resolve directory webpack issueMultiMain 中的错误无法解决目录 webpack 问题
【发布时间】:2016-11-13 22:02:49
【问题描述】:

我知道这个问题很普遍,但最好的部分是它因人而异

就我而言,我的文件夹结构是

我的文件: 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;

包.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"
}
}

我也用虚拟 json {"name":"hello"} 将 package.json 保存在我的 app 文件夹中 作为开发人员之一的建议的一部分。我已经尝试了附近所有可能的情况,但都是徒劳的。 请对此有所了解。

更新: 将文件夹从 !bharath 更改为 bharath 错误减少到 1。

【问题讨论】:

  • 您的输入为path.resolve(__dirname,'src/app/level2'),,但我在app 文件夹中的任何位置都没有看到level2.js

标签: javascript reactjs webpack babeljs webpack-dev-server


【解决方案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')
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-25
    • 2022-01-22
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 2013-10-23
    相关资源
    最近更新 更多