Closed tonyjeffreyIn closed 2 years ago
module.exports = function ({ types: t }) { return { name: 'replace-less-import-to-require', visitor: { ImportDeclaration(path){ const { node } = path; if (!node) return; const { value } = node.source; if (!value || !/\.less$/.test(value)) { return; } path.replaceWithSourceString(
require('${value}')); } } } }
you can define a babel plugin to replace import to 'require' syntax
I remember that nextjs was defined in this way before, but I don't know if it has been improved. You can try.