|
- import {
- transformDefineSingle
- } from "./chunk-SPMTHNBU.mjs";
-
- // src/index.ts
- import { createUnplugin } from "unplugin";
- import {
- REGEX_SETUP_SFC,
- REGEX_VUE_SFC,
- REGEX_VUE_SUB,
- createFilter,
- detectVueVersion
- } from "@vue-macros/common";
- import { RollupResolve, setResolveTSFileIdImpl } from "@vue-macros/api";
- function resolveOption(options, framework) {
- const version = options.version || detectVueVersion();
- return {
- include: [REGEX_VUE_SFC, REGEX_SETUP_SFC].concat(
- version === 2 && framework === "webpack" ? REGEX_VUE_SUB : []
- ),
- isProduction: process.env.NODE_ENV === "production",
- ...options,
- version
- };
- }
- var name = "unplugin-vue-single-define";
- var src_default = createUnplugin(
- (userOptions = {}, { framework }) => {
- const options = resolveOption(userOptions, framework);
- const filter = createFilter(options);
- const { resolve, handleHotUpdate } = RollupResolve();
- return {
- name,
- enforce: "pre",
- buildStart() {
- if (framework === "rollup" || framework === "vite") {
- setResolveTSFileIdImpl(resolve(this));
- }
- },
- transformInclude(id) {
- return filter(id);
- },
- transform(code, id) {
- return transformDefineSingle(code, id, options.isProduction);
- },
- vite: {
- configResolved(config) {
- options.isProduction = config.isProduction;
- },
- handleHotUpdate
- }
- };
- }
- );
-
- export {
- src_default
- };
|