"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 optimize_css_assets_webpack_plugin_1 = __importDefault(require("optimize-css-assets-webpack-plugin"));
function packageConfig(isMinimize) {
    var _a;
    var _packageConfig = {
        mode: 'production',
        devtool: 'source-map',
        entry: {
            nutui: dic_1.ROOT_PACKAGE_PATH('src/nutui.js'),
        },
        output: {
            path: dic_1.ROOT_PACKAGE_PATH('dist/'),
            filename: isMinimize ? '[name].min.js' : '[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: isMinimize,
        },
        plugins: [
            new mini_css_extract_plugin_1.default({
                filename: isMinimize ? '[name].min.css' : '[name].css',
            }),
        ],
    };
    isMinimize && ((_a = _packageConfig.plugins) === null || _a === void 0 ? void 0 : _a.push(new optimize_css_assets_webpack_plugin_1.default()));
    return webpack_merge_1.default(base_config_1.baseConfig, _packageConfig);
}
exports.packageConfig = packageConfig;
//# sourceMappingURL=package.config.js.map