W
W
webe2018-05-31 19:01:18
React
webe, 2018-05-31 19:01:18

Why doesn't historyApiFallback work?

webpack": "^4.6.0",
I use BrowserRouter in React
I follow the link 127.0.0.1:8080/faq/1111111111111 (physical transition, i.e. through the f5 button)
And the browser returns an error: GET 127.0.0.1:8080/ faq/js/bundle.js 404 (Not Found)
For real, the file is here: 127.0.0.1:8080/js/bundle.js
Please help me set up the paths so that Fallback would work in development

const Webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require('path');
const webpackConfig = {
  entry: path.resolve(__dirname, './src/index.js'),
  output: {
    path: path.resolve(__dirname, 'dest'),
    filename: "js/bundle.js"
  },
  resolve: { extensions: ['.js', '.jsx'] },
  module: {
    rules: [
    ......скрыто, ибо много ненужного.........
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, './src/index.html'),
      filename: 'index.html',
    }),
    new ExtractTextPlugin({
      disable: false,
      filename: "[name].css",
    }),
    new Webpack.ProvidePlugin({
      $demo: path.resolve(__dirname, './dest/js/demo.js'),
    }),
    new Webpack.NamedModulesPlugin(),
    new Webpack.HotModuleReplacementPlugin()
  ],
  devServer: {
    contentBase: path.resolve(__dirname, './dest'),
    port: 8080,
    historyApiFallback:true,
    inline: true,
    hot: true,
    host: '0.0.0.0'
  }
};
module.exports = webpackConfig

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question