@srejs/vue-webpack
Version:
srejs vue技术栈webpack配置工具包
23 lines (22 loc) • 1.07 kB
JavaScript
var _fs = require("fs");
var _webpackMerge = require("webpack-merge");
var _common = require("@srejs/common");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
module.exports = function (config, isServer) {
if (!_fs.existsSync(_common.webpackConfigPath)) {
return config;
}
var customConfig = config;
delete require.cache[require.resolve(_common.webpackConfigPath)];
var configureWebpack = require(_common.webpackConfigPath);
if (typeof configureWebpack === 'function') {
// apply customConfig
customConfig = Reflect.apply(configureWebpack, config, [config, isServer ? 'ssr' : 'csr']);
}
if (_typeof(configureWebpack) === 'object') {
// webpack-merge
customConfig = (0, _webpackMerge.merge)(config, configureWebpack);
}
return customConfig;
};
;