Сервер разработки Webpack возвращает 404 при приземлении не на страницу индекса.
Проблема заключается в том, что при посылке пример к localhost:8080/page
запросу приложения bundle.js
из http://localhost:8080/page/bundle.js?08386a6ab2de89169893
и затем возвращает 404
Когда запрос запроса от index http://localhost:8080/bundle.js?08386a6ab2de89169893
dev-server возвращает 200
my webpack.config. js:
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
const CompressionPlugin = require('compression-webpack-plugin')
const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default
const styledComponentsTransformer = createStyledComponentsTransformer()
const basePath = __dirname
module.exports = function(env, arg) {
const base = {
context: path.join(basePath, 'src'),
entry: ['./index.tsx'],
output: {
path: path.join(basePath, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
getCustomTransformers: () => ({
before: [styledComponentsTransformer],
}),
},
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.mjs', '.tsx', '.ts', '.js'],
alias: {
react: path.resolve(__dirname, 'node_modules', 'react'),
'~': path.resolve('./src'),
},
},
devtool: 'source-map',
externals: {
React: 'react',
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
inline: true,
compress: true,
historyApiFallback: true,
proxy: {
'/graphql': {
secure: false,
target: 'http://gepick.com:4002/graphql',
changeOrigin: true,
},
'/predict': {
secure: false,
target: 'http://localhost:5000',
changeOrigin: true,
},
},
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html', //Name of file in ./dist/
template: 'index.html', //Name of template in ./src
hash: true,
}),
],
}
return base
}