@twstyled/babel-preset
Version:
Babel plugin for twstyled -- the full-featured Tailwind CSS + CSS in JS Compiler
29 lines (28 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const babel_options_read_paths_1 = require("./babel-options-read-paths");
function getBabelOptions(options) {
if (options.babelOptions) {
return options;
}
const { paths, baseUrl } = babel_options_read_paths_1.getConfigPaths();
if (!paths) {
return options;
}
return Object.assign({ babelOptions: {
plugins: [
[
'babel-plugin-module-resolver',
{
root: [baseUrl || './'],
alias: Object.keys(paths).reduce((accum, key) => {
accum[key.replace(/\/\*$/, '')] = paths[key].map((s) => s.replace(/\/\*$/, ''))[0];
return accum;
}, {}),
extensions: ['.tsx', '.ts']
}
]
]
} }, options);
}
exports.default = getBabelOptions;