React,Webpack:未生成bundle.js

时间:2016-05-16 08:16:42

标签: javascript reactjs webpack

修改:原因是我正在运行{ intents:[ "intent" : "SaveIntent" ] } ,当它只运行SaveIntent save SaveIntent store 时就运行了。

我正在使用React和Webpack。未生成webpack-dev-server。我发现this question on SO提出了同样的问题,但我似乎已经安装了所需的依赖项。这是我的webpack.config.js:

webpack

这是我的package.json:

bundle.js

有什么想法吗?

编辑。运行webpack时的输出:

var webpack = require('webpack');    
module.exports = {
    entry: [
        'webpack-dev-server/client?http://localhost:8080',
        'webpack/hot/only-dev-server',
        './src/index.js'
    ],
    module: {
        loaders: [{
            test: /\.js?$/,
            exclude: /node_modules/,
            loader: 'react-hot!babel'
        }]
    },
    resolve: {
        extensions: ['', '.js']
    },
    output: {
        path: 'dist',
        publicPath: '/',
        filename: 'bundle.js'
    },
    devServer: {
        contentBase: './dist',
        hot: true
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin()
    ]
};

2 个答案:

答案 0 :(得分:3)

输出路径可能有问题..您可以尝试将输出路径替换为./dist

答案 1 :(得分:2)

这是由于缺少package.json脚本中的一些键值对。用以下内容替换脚本对象:

<!DOCTYPE HTML>
<html>

<head>
  <title> HellowWorld PhoneGap App </title>
  <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
</head>

<body>
  <h1>Upload images to remote server</h1>

  <div class="app">
    <h4><a href="#" onclick="capture();">Select an Image</a></h4>
    <img id="myImage" src="" width="50%">

  </div>


</body>

</html>

&#34; -p&#34;特别适用于webpack.config.js的生产环境。然后运行此cmd:"scripts": { "start": "npm run build", "build": "webpack -p && webpack-dev-server" },

$ npm start将调用$ npm start cmd,而后者将调用&#34; webpack -p&amp;&amp;的WebPack-DEV-服务器&#34;