|
| 1 | +var config = require('./webpack.config.dev'); |
| 2 | +var paths = require('./paths'); |
| 3 | + |
| 4 | +var protocol = process.env.HTTPS === 'true' ? "https" : "http"; |
| 5 | +var host = process.env.HOST || 'localhost'; |
| 6 | + |
| 7 | +module.exports = { |
| 8 | + // Enable gzip compression of generated files. |
| 9 | + compress: true, |
| 10 | + // Silence WebpackDevServer's own logs since they're generally not useful. |
| 11 | + // It will still show compile warnings and errors with this setting. |
| 12 | + clientLogLevel: 'none', |
| 13 | + // By default WebpackDevServer serves physical files from current directory |
| 14 | + // in addition to all the virtual build products that it serves from memory. |
| 15 | + // This is confusing because those files won’t automatically be available in |
| 16 | + // production build folder unless we copy them. However, copying the whole |
| 17 | + // project directory is dangerous because we may expose sensitive files. |
| 18 | + // Instead, we establish a convention that only files in `public` directory |
| 19 | + // get served. Our build script will copy `public` into the `build` folder. |
| 20 | + // In `index.html`, you can get URL of `public` folder with %PUBLIC_PATH%: |
| 21 | + // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> |
| 22 | + // In JavaScript code, you can access it with `process.env.PUBLIC_URL`. |
| 23 | + // Note that we only recommend to use `public` folder as an escape hatch |
| 24 | + // for files like `favicon.ico`, `manifest.json`, and libraries that are |
| 25 | + // for some reason broken when imported through Webpack. If you just want to |
| 26 | + // use an image, put it in `src` and `import` it from JavaScript instead. |
| 27 | + contentBase: paths.appPublic, |
| 28 | + // Enable hot reloading server. It will provide /sockjs-node/ endpoint |
| 29 | + // for the WebpackDevServer client so it can learn when the files were |
| 30 | + // updated. The WebpackDevServer client is included as an entry point |
| 31 | + // in the Webpack development configuration. Note that only changes |
| 32 | + // to CSS are currently hot reloaded. JS changes will refresh the browser. |
| 33 | + hot: true, |
| 34 | + // It is important to tell WebpackDevServer to use the same "root" path |
| 35 | + // as we specified in the config. In development, we always serve from /. |
| 36 | + publicPath: config.output.publicPath, |
| 37 | + // WebpackDevServer is noisy by default so we emit custom message instead |
| 38 | + // by listening to the compiler events with `compiler.plugin` calls above. |
| 39 | + quiet: true, |
| 40 | + // Reportedly, this avoids CPU overload on some systems. |
| 41 | + // https://github.com/facebookincubator/create-react-app/issues/293 |
| 42 | + watchOptions: { |
| 43 | + ignored: /node_modules/ |
| 44 | + }, |
| 45 | + // Enable HTTPS if the HTTPS environment variable is set to 'true' |
| 46 | + https: protocol === "https", |
| 47 | + host: host |
| 48 | +}; |
0 commit comments