MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / vueConfig

Function vueConfig

packages/vite/configuration/vue.ts:18–177  ·  view source on GitHub ↗
({ mode })

Source from the content-addressed store, hash-verified

16const __dirname = dirname(__filename);
17
18export const vueConfig = ({ mode }): UserConfig => {
19 const targetMode = mode === 'development' ? 'development' : 'production';
20 const cliFlags = getCliFlags();
21 const isDevMode = targetMode === 'development';
22 const hmrActive = isDevMode && !!cliFlags.hmr;
23
24 return mergeConfig(baseConfig({ mode }), {
25 plugins: [
26 {
27 ...alias({
28 entries: {
29 // Retain 'vue' alias to 'nativescript-vue' so any generic Vue imports resolve
30 // to the NativeScript-Vue runtime.
31 vue: 'nativescript-vue',
32 'set-value': resolve(__dirname, '../shims/set-value.js'),
33 },
34 }),
35 enforce: 'pre',
36 },
37 // Enable Vue Single File Component support
38 vue({
39 // NativeScript projects often use <script setup lang="ts">
40 script: {
41 defineModel: true,
42 propsDestructure: true,
43 },
44 // Keep template compilation basic; transform asset URLs is not needed for NS
45 template: {
46 transformAssetUrls: false,
47 compilerOptions: {
48 // Only treat real web custom elements (hyphenated) as custom.
49 // DO NOT match PascalCase NativeScript tags.
50 isCustomElement: (tag) => tag.includes('-'),
51 },
52 },
53 }),
54 // Optional: allow JSX/TSX in Vue components if used
55 vueJsx(),
56 // With HMR, apply post-transform to make any named import from 'nativescript-vue' bulletproof in build mode.
57 // It rewrites `import { X as Y } from 'nativescript-vue'` to a namespace import and
58 // creates local const bindings that pick from either the module's named export (if present)
59 // or the default object's property, auto-binding functions to the default instance.
60 hmrActive
61 ? {
62 name: 'ns-vue-named-imports-interop',
63 apply: 'build',
64 enforce: 'post',
65 transform(code: string, id: string) {
66 // Only operate on JS/TS and extracted Vue script blocks
67 if (!/\.(mjs|cjs|js|ts|jsx|tsx)(\?|$)/.test(id) && !/\.vue\?vue&type=script/.test(id)) {
68 return null;
69 }
70 let ast: any;
71 try {
72 ast = babelParse(code, {
73 sourceType: 'module',
74 plugins: [
75 'typescript',

Callers

nothing calls this directly

Calls 5

getCliFlagsFunction · 0.85
baseConfigFunction · 0.85
aliasFunction · 0.85
includesMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected