Expand edge gateway workspace and streamline app loading
This commit is contained in:
+38
-3
@@ -61,6 +61,22 @@ function patchBuefyCssMediaQuery() {
|
||||
}
|
||||
}
|
||||
|
||||
function stripBrokenVueToastNotificationSourceMap() {
|
||||
return {
|
||||
name: 'strip-broken-vue-toast-notification-sourcemap',
|
||||
enforce: 'pre',
|
||||
load(id) {
|
||||
if (id.startsWith('\0') || !id.includes('vue-toast-notification/dist/index.js')) {
|
||||
return null
|
||||
}
|
||||
|
||||
const filePath = id.split('?')[0]
|
||||
const code = fs.readFileSync(filePath, 'utf8')
|
||||
return code.replace(/\n?\/\/\# sourceMappingURL=mitt\.mjs\.map\s*$/m, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadVitePwaPlugin(workspaceRoot) {
|
||||
const localPluginEntry = path.resolve(workspaceRoot, 'node_modules.external-link', 'vite-plugin-pwa', 'dist', 'index.js')
|
||||
|
||||
@@ -81,6 +97,13 @@ export default defineConfig(async ({ mode }) => {
|
||||
const isPlaywrightRuntime = process.env.PLAYWRIGHT === '1'
|
||||
const shouldDisableDepOptimizer = process.platform === 'win32'
|
||||
const workspaceRoot = process.cwd()
|
||||
const vueToastNotificationSourceEntry = path.resolve(
|
||||
workspaceRoot,
|
||||
'node_modules',
|
||||
'vue-toast-notification',
|
||||
'src',
|
||||
'index.js'
|
||||
)
|
||||
const vitePwaModule = await loadVitePwaPlugin(workspaceRoot)
|
||||
const VitePWA = vitePwaModule?.VitePWA
|
||||
|
||||
@@ -121,6 +144,7 @@ export default defineConfig(async ({ mode }) => {
|
||||
base,
|
||||
plugins: [
|
||||
patchBuefyCssMediaQuery(),
|
||||
stripBrokenVueToastNotificationSourceMap(),
|
||||
vue(),
|
||||
VueJsx(),
|
||||
!isProd && !isPlaywrightRuntime && vueDevTools(),
|
||||
@@ -214,11 +238,21 @@ export default defineConfig(async ({ mode }) => {
|
||||
})
|
||||
].filter(Boolean),
|
||||
resolve: {
|
||||
alias: {
|
||||
preserveSymlinks: true,
|
||||
alias: [
|
||||
// Anchor aliases to the active workspace so hardlinked worktrees do not
|
||||
// accidentally resolve into a sibling checkout.
|
||||
'@': path.resolve(workspaceRoot, 'src')
|
||||
}
|
||||
{
|
||||
find: '@',
|
||||
replacement: path.resolve(workspaceRoot, 'src')
|
||||
},
|
||||
// On Windows we disable dependency prebundling, so package-root imports must
|
||||
// stay on the ESM source entry instead of the published UMD bundle.
|
||||
{
|
||||
find: /^vue-toast-notification$/,
|
||||
replacement: vueToastNotificationSourceEntry
|
||||
}
|
||||
]
|
||||
},
|
||||
define: {
|
||||
'import.meta.env.VITE_BUILD_DATE': JSON.stringify(new Date().toISOString()),
|
||||
@@ -226,6 +260,7 @@ export default defineConfig(async ({ mode }) => {
|
||||
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(commit),
|
||||
// Tip: import.meta.env.DEV/PROD are available at runtime
|
||||
'import.meta.env.VITE_IS_DEV': JSON.stringify(!isProd),
|
||||
'import.meta.env.VITE_IS_PLAYWRIGHT': JSON.stringify(isPlaywrightRuntime),
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
|
||||
Reference in New Issue
Block a user