2

以下craco配置取自 Internet 上的多篇文章,这些文章展示了如何将 monorepo UI 库包含到 CRA 构建流程中:

const path = require('path');
const { getLoader, loaderByName } = require('@craco/craco');

const uiPath = path.join(__dirname, '../../packages/ui');

module.exports = {
    webpack: {
        alias: {},
        plugins: [],
        configure: (webpackConfig, { env, paths }) => {
            const { isFound, match } = getLoader(webpackConfig, loaderByName('babel-loader'));
            if (isFound) {
                const include = Array.isArray(match.loader.include) ? match.loader.include : [match.loader.include];
                match.loader.include = include.concat([uiPath]);
            }
            return webpackConfig;
        },
    },
};

...效果很好,但我不明白为什么我的 IDE 一直显示Value assigned to primitive will be lost以下行的警告:

match.loader.include = include.concat([uiPath]);

4

0 回答 0