Inspired from https://www.npmjs.com/package/babel-plugin-ignore-import and since I needed this functionality, as it was blocker was moving to SWC.
const swc = require("@swc/core");
const PluginIgnoreImport = require("swc-plugin-ignore-import").default;
const { code } = swc.transformSync(src, {
filename: "source-file-name-for-sourcemap.js",
sourceMaps: true,
jsc: {
parser: {
syntax: "ecmascript",
},
target: "es2015",
},
plugin: (m) =>
new PluginIgnoreImport({
pattern: /\.s?css$/,
}).visitProgram(m),
});
npx prettier --write index.ts
Licensed under the MIT license.
Copyright (c) Juga Paazmaya [email protected]