Advertisement
Guest User

webpackDevServer.config.js

a guest
Mar 21st, 2018
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
  4. const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
  5. const path = require('path');
  6. const config = require('./webpack.config.dev');
  7. const paths = require('./paths');
  8.  
  9. const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
  10. const host = process.env.HOST || '0.0.0.0';
  11.  
  12. module.exports = function(proxy, allowedHost) {
  13.   return {
  14.     disableHostCheck:
  15.       !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
  16.     compress: true,
  17.     clientLogLevel: 'none',
  18.     contentBase: paths.appPublic,
  19.     watchContentBase: true,
  20.     hot: true,
  21.     publicPath: config.output.publicPath,
  22.     quiet: true,
  23.     watchOptions: {
  24.       ignored: new RegExp(
  25.         `^(?!${path
  26.           .normalize(paths.appSrc + '/')
  27.           .replace(/[\\]+/g, '\\\\')}).+[\\\\/]node_modules[\\\\/]`,
  28.         'g'
  29.       ),
  30.     },
  31.     // Enable HTTPS if the HTTPS environment variable is set to 'true'
  32.     https: protocol === 'https',
  33.     host: host,
  34.     overlay: false,
  35.     historyApiFallback: {
  36.       // Paths with dots should still use the history fallback.
  37.       // See https://github.com/facebookincubator/create-react-app/issues/387.
  38.       disableDotRule: true,
  39.     },
  40.     public: allowedHost,
  41.     proxy,
  42.     before(app) {
  43.       // This lets us open files from the runtime error overlay.
  44.       app.use(errorOverlayMiddleware());
  45.       // This service worker file is effectively a 'no-op' that will reset any
  46.       // previous service worker registered for the same host:port combination.
  47.       // We do this in development to avoid hitting the production cache if
  48.       // it used the same host and port.
  49.       // https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
  50.       app.use(noopServiceWorkerMiddleware());
  51.     },
  52.   };
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement