0.0.0 • Published 6 years ago

webpack-serve-addons-history-api-callback v0.0.0

Weekly downloads
147
License
MIT
Repository
github
Last release
6 years ago

webpack-serve-addons-history-api-callback

Usage

  1. npm install -D webpack-serve-addons-history-api-callback
  2. Add the following to your webpack-serve config

example of serve.config.js

const historyApiFallbackAddon = require('webpack-serve-addons-history-api-callback').addon;

module.exports = {
  config: './webpack.config.js',
  content: './public',
  add: historyApiFallbackAddon,
};
  1. Run webpack-serve

Use with other addons/middlewares

example of serve.config.js

const historyApiFallback = require('webpack-serve-addons-history-api-callback');

module.exports = {
  config: './webpack.config.js',
  content: './public',
  add: (app, middleware, options) => {
    app.use(anotherAddon());
    app.use(historyApiFallback());
  },
};

Options

app.use(historyApiFallback({ /* options */ }));

See: https://github.com/bripkens/connect-history-api-fallback#options

There's frequently used options in the following.

OptionTypeDefault valueDescription
indexstring/index.htmlOverride the index
rewrites{ from: string, to: string }[]Override the index when the request url matches a regex pattern
htmlAcceptHeadersstring[]['text/html', '*/*']Override the default accepts request headers