GET http://equalityfits.com/bundle.js net :: ERR_ABORTED 404(未找到)Apache2 WebServer

时间:2020-06-24 22:43:05

标签: javascript reactjs apache webpack

我正在为我的本地环境使用webpack reat和yarn,该环境正在jsut查找中工作,包括查找和捆绑bundle.js。但是现在我试图使用数字海洋和Apache在Web服务器上设置我的环境,但我似乎无法使其正常工作。我认为我已经正确设置了它,但是一直在尝试各种修复程序,但是没有任何效果。当我转到服务器地址时,只是得到标题中的错误,并且找不到https:(myhostname)/bundle.js。在下面请张贴我的webpack,package和apache配置。

Webpack配置

var webpack = require('webpack')
var path = require('path')

module.exports = {
  devServer: {
    contentBase: path.resolve(__dirname, './public'),
    historyApiFallback: true,
  },
  entry: path.resolve(__dirname, './src/index.js'),
  resolve: {
    extensions: ['*', '.js', '.jsx'],
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/env', '@babel/react'],
              plugins: ['@babel/plugin-transform-runtime'],
            },
          },
        ],
      },

      {
        test: /\.(css|sass|scss)$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              sourceMap: true,
              importLoaders: 2,
            },
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true,
            },
          },
        ],
      },
{
        test: /\.(css|sass|scss)$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              sourceMap: true,
              importLoaders: 2,
            },
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true,
            },
          },
        ],
      },
      {
        test: /\.svg$/,
        use: [
          {
            loader: 'svg-inline-loader',
            options: {
              limit: 10000,
            },
          },
        ],
      },
    ],
  },
  output: {
    path: path.join(__dirname, './public'),
    filename: 'bundle.js',
  },
}

package.json

{
  "homepage": "./",
  "name": "EqalityFits-dot-com",
  "version": "1.0.0",
  "main": "./src/index.js",
  "license": "TBA",
  "devDependencies": {
    "@babel/core": "^7.10.2",
    "@babel/preset-env": "^7.10.2",
    "@babel/preset-react": "^7.10.1",
    "babel-loader": "^8.1.0",
    "bootstrap": "^4.5.0",
    "react-bootstrap": "^1.0.1",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^3.11.0"
  },
  "dependencies": {
    "@auth0/auth0-spa-js": "^1.10.0",
    "@babel/plugin-proposal-class-properties": "^7.10.1",
    "@babel/plugin-syntax-class-properties": "^7.10.1",
    "@babel/plugin-transform-runtime": "^7.10.3",
    "bootstrap": "^4.5.0",
    "css-loader": "^3.5.3",
    "jquery": "^3.5.1",
    "node-sass": "^4.14.1",
    "popper.js": "^1.16.1",
    "postcss-loader": "^3.0.0",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.1",
    "react-dom": "^16.13.1",
    "react-icons": "^3.10.0",
    "react-router-dom": "^5.2.0",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.2.1",
    "svg-inline-loader": "^0.8.2"
  },
  "scripts": {
    "start": "webpack-dev-server --progress",
    "production": "webpack -p --progress"
  }
}

apache网站配置

<VirtualHost *:80>
    ServerAdmin equalityfits@localhost
    ServerName equalityfits.com
    ServerAlias www.equalityfits.com
    DirectoryIndex index.html
    DocumentRoot /var/www/EqualityTee/front-end/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/Eqia;otyTee/front-end/public">
        RewriteEngine on
        # Don't rewrite files or directories
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]
        # Rewrite everything else to index.html to allow html5 state links
        RewriteRule ^ index.html [L]
    </Directory>

</VirtualHost>

我对如何做感到非常困惑,将不胜感激。

0 个答案:

没有答案