Firebase,React,Webpack - 部署时如何更改配置?

时间:2016-05-16 10:42:52

标签: javascript reactjs firebase webpack

我正在使用React和Webpack构建SPA,并使用Firebase进行存储和托管。 我只是尝试部署它,虽然它没有喷射完成。首先,我在控制台中遇到了很多错误:

Mixed Content: The page at 'https://plump.firebaseapp.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:8080/sockjs-node/info?t=1463392450338'. This request has been blocked; the content must be served over HTTPS.

我知道它从localhost请求是错误的,但我不知道如何解决这个问题。我也不明白究竟没有通过https提供什么。

此外,当我进行一些更改并再次部署时,部署的版本不会更新。我找到了this question on SO,看来我遇到了同样的问题。

这是我的webpack.config.js

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()
    ]
};

的index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
    <link rel="stylesheet" type="text/css" href="mystyle.css">
  </head>
  <body>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '578503765660056',
          xfbml      : true,
          version    : 'v2.5'
        });
      };
      (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/swe_sv/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>
      <div id="app"></div>
      <script src="bundle.js"></script>
  </body>
</html>

0 个答案:

没有答案