test02/node_modules/@vuepress/helper/lib/node/bundler/webpack.js
罗佳鸿 6aa1ebe342
Some checks are pending
部署文档 / deploy-gh-pages (push) Waiting to run
first commit
2024-08-13 10:11:19 +08:00

23 lines
1.0 KiB
JavaScript

import { getBundlerName } from './getBundlerName.js';
export const chainWebpack = (bundlerOptions, app, chainWebpack) => {
if (getBundlerName(app) === 'webpack') {
const webpackBundlerOptions = bundlerOptions;
const { chainWebpack: originalChainWebpack } = webpackBundlerOptions;
webpackBundlerOptions.chainWebpack = (config, isServer, isBuild) => {
originalChainWebpack?.(config, isServer, isBuild);
chainWebpack(config, isServer, isBuild);
};
}
};
export const configWebpack = (bundlerOptions, app, configureWebpack) => {
if (getBundlerName(app) === 'webpack') {
const webpackBundlerOptions = bundlerOptions;
const { configureWebpack: originalConfigWebpack } = webpackBundlerOptions;
webpackBundlerOptions.configureWebpack = (config, isServer, isBuild) => {
const result = originalConfigWebpack?.(config, isServer, isBuild);
configureWebpack(config, isServer, isBuild);
return result;
};
}
};