craco icon indicating copy to clipboard operation
craco copied to clipboard

How can i merge these two configure props in webpack config override (craco.config.js)?

Open igorkis-scrts opened this issue 5 years ago • 1 comments

Hello! Sorry for bothering and asking silly questions, but i'm making my first steps in overriding CRA without ejecting and i'm confused - how to have one configure property instead of two ones (as on example below)?

Example:

const path = require('path');
const tsNameof = require("ts-nameof");

const overridenPaths = require('./config/paths');

module.exports = {
    webpack: {
        alias: {
            '@public': path.resolve(__dirname, "public/"),
            '@': path.resolve(__dirname, "src/"),
        },
        configure: {
            module: {
                rules: [
                    {
                        test: /\.(ts|tsx)$/,
                        exclude: /node_modules/,
                        use: [
                            {
                                loader: require.resolve('ts-loader'),
                                options: {
                                    transpileOnly: true,
                                    getCustomTransformers: () => ({before: [tsNameof]}),
                                },
                            },
                        ],
                    },
                ],
            },
        },
        configure: (webpackConfig, {env, paths}) => {
            paths.appBuild = webpackConfig.output.path = overridenPaths.customBuildDir;
            return webpackConfig;
        }
    }
}

igorkis-scrts avatar Jan 20 '21 11:01 igorkis-scrts

Nevermind.

igorkis-scrts avatar Jan 20 '21 12:01 igorkis-scrts