"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
function getBaseConfig(paths, libName) {
    const { autoRequireTempPath, autoRequireMetaTempPath, outputPath } = paths;
    return {
        entry: {
            main: autoRequireTempPath,
            meta: autoRequireMetaTempPath,
        },
        output: {
            path: outputPath,
            filename: `${libName}.[name].[hash].js`,
            library: `@impage-materials-[name]-${libName}`,
            libraryTarget: 'window',
            umdNamedDefine: true,
        },
        resolve: {
            modules: [
                paths.srcPath,
                path.resolve(paths.srcPath, './lib/edu_modules'),
                path.resolve(paths.rootPath, './node_modules'),
            ],
            alias: {
                zepto: 'zepto-webpack',
            },
        },
        module: {
            rules: [
                {
                    test: /\.(js|jsx)$/,
                    loader: 'babel-loader',
                    options: {
                        presets: [
                            [
                                '@babel/preset-env',
                                {
                                    targets: {
                                        chrome: '58',
                                    },
                                },
                            ],
                            '@babel/preset-react',
                        ],
                        plugins: [
                            '@babel/plugin-proposal-class-properties',
                            ['@babel/plugin-proposal-decorators', { legacy: true }],
                            '@babel/plugin-proposal-export-default-from',
                            '@babel/plugin-proposal-export-namespace-from',
                            '@babel/plugin-proposal-optional-chaining',
                            '@babel/plugin-proposal-partial-application',
                            [
                                '@babel/plugin-proposal-pipeline-operator',
                                { proposal: 'fsharp' },
                            ],
                        ],
                    },
                },
                {
                    test: /\.(css|scss|sass)$/,
                    use: [
                        {
                            loader: require('extract-css-chunks-webpack-plugin').loader,
                            options: {
                                hot: true,
                                reloadAll: true,
                            },
                        },
                        { loader: 'css-loader' },
                        {
                            loader: 'sass-loader',
                            options: {
                                implementation: require('dart-sass'),
                            },
                        },
                    ],
                },
                {
                    test: /\.(jpe?g|png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
                    loader: 'base64-inline-loader',
                },
                {
                    test: /\.tpl$/,
                    loader: path.resolve(__dirname, '../loader/tpl-loader'),
                },
                {
                    test: /\.ejs$/,
                    use: 'raw-loader',
                },
            ],
        },
        optimization: {
            minimize: false,
        },
        externals: {
            react: 'React',
            antd: 'Antd',
            'react-dom': 'ReactDom',
            'react-dom/server': 'ReactDomServer',
        },
        plugins: [
            new ExtractCssChunks({
                filename: `${libName}.[name].[hash].css`,
                orderWarning: true,
            }),
        ],
    };
}
exports.getBaseConfig = getBaseConfig;
//# sourceMappingURL=base.js.map