module.exports = require("babel-loader").custom(babel => {
    // function myPlugin() {
    //     return {
    //         visitor: {},
    //     };
    // }

    return {
        // Passed the loader options.
        customOptions({ /*opt1, opt2,*/ ...loader }) {
            return {
                // Pull out any custom options that the loader might have.
                custom: { /*opt1, opt2*/ },

                // Pass the options back with the two custom options removed.
                loader,
            };
        },

        // Passed Babel's 'PartialConfig' object.
        config(cfg) {
            // if (cfg.hasFilesystemConfig()) {
            //     // Use the normal config
            //     return cfg.options;
            // }

            const { plugins, ...options } = cfg.options

            /** @type {Boolean} 已有的 plugin 中是否存在 `react-hot-loader/babel` */
            let hasRHL = false
            const newPlugins = plugins.filter(plugin => {
                if (typeof plugin.file === 'object' &&
                    /react-hot-loader(\/|\\)babel/.test(plugin.file.request)
                ) {
                    hasRHL = true
                    // 非开发模式下不应存在 RHL
                    if (process.env.WEBPACK_BUILD_ENV !== 'dev') {
                        return false
                    }
                }
                // console.log(plugin.file.request)
                return true
            })
            if (!hasRHL &&
                process.env.WEBPACK_BUILD_ENV === 'dev'
            ) {
                newPlugins.push(require('react-hot-loader/babel'))
            }

            // console.log('')
            // console.log({
            //     'plugin[].file': newPlugins.map(plugin => {
            //         return plugin.file.request
            //     })
            // })
            // console.log('')

            return {
                ...options,
                plugins: newPlugins,
            };
        },

        result(result) {
            return {
                ...result,
                // code: result.code + "\n// Generated by some custom loader",
            };
        },
    };
});

@@ -769,16 +769,25 @@
  const %7B
+ presets,
  plugins
@@ -816,16 +816,727 @@
 ptions%0A%0A
+            const newPresets = presets.map(preset =%3E %7B%0A                if (typeof preset.file === 'object' &&%0A                    /%5E@babel%5C/preset-env$/.test(preset.file.request)%0A                ) %7B%0A                    if (!preset.options)%0A                        preset.options = %7B%7D%0A                    if (process.env.WEBPACK_BUILD_STAGE === 'server') %7B%0A                        preset.options.modules = 'auto'%0A                        // preset.options.targets = %7B%0A                        //     node: %228%22%0A                        // %7D%0A                        // console.log(preset.options)%0A                    %7D%0A                    return preset%0A                %7D%0A                return preset%0A            %7D)%0A%0A
         
@@ -2368,16 +2368,222 @@
 log('')%0A
+            // presets.forEach(preset =%3E %7B%0A            //     console.log('')%0A            //     console.log('options', preset.options)%0A            //     console.log('file', preset.file)%0A            // %7D)%0A
         
@@ -2801,32 +2801,32 @@
        return %7B%0A
-
                 
@@ -2833,24 +2833,61 @@
 ...options,%0A
+                presets: newPresets,%0A
             

modify `@babel/preset-env`