diff --git a/src/index.js b/src/index.js index d479620..047ec84 100644 --- a/src/index.js +++ b/src/index.js @@ -4,8 +4,16 @@ const CircularDependencyPlugin = require('circular-dependency-plugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const CWD = process.cwd(); -const POLYFILLS = [require.resolve('raf/polyfill')]; + +const POLYFILLS = [ + require.resolve('babel-polyfill'), + require.resolve('raf/polyfill'), +]; + +const { HOST = '0.0.0.0', PORT = 3000 } = process.env; + const MATCHES_LEADING_DOT = /^\./; +const MATCHES_LEADING_DOT_SLASHES = /^[\.\/]+/; function validateOptions(options) { if (!options || typeof options !== 'object' || Array.isArray(options)) { @@ -231,6 +239,13 @@ function createWebpackConfig(options) { '^': rootDir, }, }, + devServer: { + contentBase: CWD, + publicPath: options.outDir.replace(MATCHES_LEADING_DOT_SLASHES, ''), + port: PORT, + host: HOST, + historyApiFallback: true, + }, plugins: [ new ForkTsCheckerWebpackPlugin(), new CircularDependencyPlugin({