vite-plugin-twstyled
Version:
Vite plugin for twstyled -- the full-featured Tailwind CSS + CSS in JS Compiler
37 lines (36 loc) • 1.84 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const babel_preset_1 = __importDefault(require("@twstyled/babel-preset"));
const babel_rollup_1 = __importDefault(require("./babel-rollup"));
function Plugin(options) {
var _a;
const babel = (_a = options === null || options === void 0 ? void 0 : options.babel) !== null && _a !== void 0 ? _a : {};
const { plugins, presets } = babel, babelOptions = __rest(babel, ["plugins", "presets"]);
const babelPlugins = [...(plugins || [])];
const babelPresets = [babel_preset_1.default, ...(presets || [])];
return Object.assign(Object.assign({}, babel_rollup_1.default(Object.assign({ extensions: ['tsx', 'ts'], presets: babelPresets, plugins: babelPlugins, babelrc: false, babelHelpers: 'bundled' }, (babelOptions || options)))), { config(config) {
return {
// only apply esbuild to non tsx files
// since we are handling tsx now
esbuild: {
include: /\.(js|jsx|ts)$/
},
define: Object.assign({}, config.define)
};
}, name: require('../package.json').name });
}
exports.default = Plugin;