1 | import { existsSync } from 'fs';
|
2 | import { join } from 'path';
|
3 | import chalk from 'chalk';
|
4 | import webpack from 'webpack';
|
5 |
|
6 | export function warnIfExists(cwd) {
|
7 | const filePath = join(cwd, 'webpack.config.js');
|
8 | if (existsSync(filePath)) {
|
9 | console.log(
|
10 | chalk.yellow(
|
11 | `⚠️ ⚠️ ⚠️ It\\'s not recommended to use ${chalk.bold(
|
12 | 'webpack.config.js',
|
13 | )}, since it\\'s major or minor version upgrades may result in incompatibility. If you insist on doing so, please be careful of the compatibility after upgrading.`,
|
14 | ),
|
15 | );
|
16 | console.log();
|
17 | }
|
18 | }
|
19 |
|
20 | export function applyWebpackConfig(cwd, config) {
|
21 | const filePath = join(cwd, 'webpack.config.js');
|
22 | if (existsSync(filePath)) {
|
23 | let customConfigFn = require(filePath);
|
24 | if (customConfigFn.default) {
|
25 | customConfigFn = customConfigFn.default;
|
26 | }
|
27 | return customConfigFn(config, {
|
28 |
|
29 | webpack,
|
30 | });
|
31 | } else {
|
32 | return config;
|
33 | }
|
34 | }
|