tb-harmony-modern-ts/bblloader.ts
2025-11-13 12:14:15 +01:00

43 lines
998 B
TypeScript

import babelLoader from "babel-loader";
import { ConfigItem } from "@babel/core";
export default babelLoader.custom(() => {
// Extract the custom options in the custom plugin
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: ConfigItem) {
return {
...cfg.options,
plugins: [
...((cfg.options && cfg.options["plugins"]) || []),
[myPlugin],
],
};
},
// result(result) {
// return {
// ...result,
// code: result.code + "\n// Generated by some custom loader",
// };
// },
};
});