"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const path_1 = require("path");
const resolve_1 = require("resolve");
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
const typescript_1 = require("typescript");
exports.defaultWebpackConfig = (cwd, input, output) => {
    const configFile = typescript_1.findConfigFile(cwd, (fileName) => fs_1.existsSync(fileName));
    const tsLoader = resolve_1.sync('ts-loader', { basedir: __dirname });
    if (!configFile) {
        throw new Error('Unable to find TypeScript configuration');
    }
    return {
        mode: 'development',
        entry: input,
        devtool: 'inline-source-map',
        output: {
            path: path_1.dirname(output),
            filename: path_1.basename(output),
            library: 'TypedTest',
            libraryTarget: 'umd',
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    loader: tsLoader,
                    options: {
                        transpileOnly: true,
                        configFile,
                    },
                },
            ],
        },
        resolve: {
            mainFields: ['module', 'jsnext:main', 'browser', 'main'],
            extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
            plugins: [new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({ configFile })],
        },
    };
};
//# sourceMappingURL=defaultWebpackConfig.js.map