"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var webpack_merge_1 = __importDefault(require("webpack-merge"));
var dic_1 = require("../util/dic");
var base_config_1 = require("./base.config");
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
var copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
var optimize_css_assets_webpack_plugin_1 = __importDefault(require("optimize-css-assets-webpack-plugin"));
var confs = require(dic_1.ROOT_PACKAGE_PATH('src/config.json'));
function packageDisperseConfig() {
    var entry = {};
    confs.packages.map(function (item) {
        var cptName = item.name.toLowerCase();
        entry[cptName] = dic_1.ROOT_PACKAGE_PATH("src/packages/" + cptName + "/index.js");
    });
    var _packageDisperseConfig = {
        mode: 'production',
        devtool: 'source-map',
        entry: entry,
        output: {
            path: dic_1.ROOT_PACKAGE_PATH('dist/packages/'),
            filename: '[name]/[name].js',
            library: '[name]',
            libraryTarget: 'umd',
            umdNamedDefine: true,
            // https://stackoverflow.com/questions/49111086/webpack-4-universal-library-target
            globalObject: "(typeof self !== 'undefined' ? self : this)",
        },
        externals: {
            vue: {
                root: 'Vue',
                commonjs: 'vue',
                commonjs2: 'vue',
                amd: 'vue',
            },
        },
        optimization: {
            minimize: true,
        },
        plugins: [
            new mini_css_extract_plugin_1.default({
                filename: '[name]/[name].css',
            }),
            new optimize_css_assets_webpack_plugin_1.default(),
            new copy_webpack_plugin_1.default([
                {
                    from: dic_1.ROOT_PACKAGE_PATH('src/'),
                    to: dic_1.ROOT_PACKAGE_PATH('dist/'),
                    ignore: ['demo.vue', 'doc.md', 'config.json', 'nutui.js', '*.spec.js'],
                },
            ]),
            new copy_webpack_plugin_1.default([
                {
                    from: dic_1.ROOT_PACKAGE_PATH('types/'),
                    to: dic_1.ROOT_PACKAGE_PATH('dist/types/'),
                },
            ]),
        ],
    };
    return webpack_merge_1.default(base_config_1.baseConfig, _packageDisperseConfig);
}
exports.packageDisperseConfig = packageDisperseConfig;
//# sourceMappingURL=package.disperse.config.js.map