"use strict";

var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));

var _path = require("path");

var _debug = _interopRequireDefault(require("debug"));

var _webpack = _interopRequireDefault(require("webpack"));

var _yargs = require("yargs");

var _webpackMerge = _interopRequireDefault(require("webpack-merge"));

var _koaConnect = _interopRequireDefault(require("koa-connect"));

var _connectHistoryApiFallback = _interopRequireDefault(require("connect-history-api-fallback"));

var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");

var _extendWebpackConfig = _interopRequireDefault(require("../../utils/extendWebpackConfig"));

var _babelDefine = _interopRequireDefault(require("../../babel-define"));

var plugins = _interopRequireWildcard(require("./webpack.plugins"));

var _webpack3 = _interopRequireWildcard(require("./webpack.config"));

const INCLUDE_CSS_FILES = process.env.INCLUDE_CSS_FILES; // delete defaultConfig.entry //TODO: why this?

const noop = () => {};

const config = (0, _extendWebpackConfig.default)((0, _webpackMerge.default)(_webpack3.default, {
  devtool: 'cheap-module-source-map',
  mode: 'development',
  // devtool: 'source-map',
  output: {
    pathinfo: true,
    filename: '[name]/[name].[hash].js'
  },
  plugins: [//new BundleAnalyzerPlugin(), // This can be used to visually get package sizes
  new plugins.ExtractTextPlugin({
    filename: '[name].[hash].css',
    allChunks: false,
    disable: !INCLUDE_CSS_FILES
  }), new _webpack.default.DefinePlugin((0, _babelDefine.default)('development'))],
  serve: {
    hotClient: true,
    port: _webpack3.PORT,
    content: _webpack3.ROOT_PATH,
    add: app => app.use((0, _koaConnect.default)((0, _connectHistoryApiFallback.default)())),
    devMiddleware: {
      stats: {
        colors: true,
        hash: false,
        version: false,
        timings: false,
        assets: false,
        chunks: false,
        modules: false,
        reasons: false,
        children: false,
        source: false,
        errors: true,
        errorDetails: true,
        warnings: true,
        publicPath: false
      }
    }
  }
}), _webpack3.ROOT_PATH, plugins);
(0, _debug.default)('webpack:config')(`Entries: ${(0, _stringify.default)(config, null, 4)}`);
var _default = config;
exports.default = _default;
module.exports = exports.default;