Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack dev server #8

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
17 changes: 16 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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({
Expand Down