diff --git a/src/core/index.ts b/src/core/index.ts index d6727a0..04969fc 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -2,11 +2,12 @@ import { type UnpluginFactory, createUnplugin } from 'unplugin'; import { createFilter } from '@rollup/pluginutils'; import { type ResolvedOptions, type Options } from '../types'; import { TRACE_ID } from './constants'; +import { isDev } from './isDev'; import { parse_ID } from './parse_ID'; import { transform } from './transform'; export const unpluginFactory: UnpluginFactory = (options = {}) => { - if (process.env.NODE_ENV !== 'development') { + if (!isDev()) { return { name: 'unplugin-vue-source', }; diff --git a/src/core/isDev.ts b/src/core/isDev.ts new file mode 100644 index 0000000..c56b541 --- /dev/null +++ b/src/core/isDev.ts @@ -0,0 +1,3 @@ +export function isDev() { + return !(process.env.NODE_ENV && process.env.NODE_ENV !== 'development'); +} diff --git a/src/vue.ts b/src/vue.ts index 4f2baa4..660a315 100644 --- a/src/vue.ts +++ b/src/vue.ts @@ -1,7 +1,8 @@ import { TRACE_ID } from './core/constants'; +import { isDev } from './core/isDev'; export default { install(app: any) { - if (process.env.NODE_ENV === 'development') { + if (isDev()) { app.mixin({ props: { [TRACE_ID]: String,