Skip to content

Commit 02d5c93

Browse files
committed
fix(app-vite): correctly supply capacitor packages (and anything installed into /src-capacitor) #12812
1 parent e54ac8e commit 02d5c93

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

app-vite/lib/config-tools.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ function createViteConfig (quasarConf, quasarRunMode) {
9393
mode: ctx.dev === true ? 'development' : 'production',
9494
cacheDir,
9595

96-
resolve: build.resolve,
96+
resolve: {
97+
alias: build.alias
98+
},
9799
define: parseEnv(build.env, build.rawDefine),
98100

99101
build: {

app-vite/lib/modes/capacitor/capacitor-config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ const path = require('path')
22

33
const appPaths = require('../../app-paths')
44
const { createViteConfig, extendViteConfig } = require('../../config-tools')
5+
const escapeRegexString = require('../../helpers/escape-regex-string')
56

67
const { dependencies } = require(appPaths.resolve.capacitor('package.json'))
78
const target = appPaths.resolve.capacitor('node_modules')
89

910
const depsList = Object.keys(dependencies)
11+
const capacitorRE = new RegExp('^(' + depsList.map(escapeRegexString).join('|') + ')')
1012

1113
module.exports = {
1214
vite: quasarConf => {
@@ -19,6 +21,15 @@ module.exports = {
1921
cfg.resolve.alias[dep] = path.join(target, dep)
2022
})
2123

24+
cfg.plugins.unshift({
25+
name: 'quasar:resolve-capacitor-deps',
26+
resolveId (id) {
27+
if (capacitorRE.test(id)) {
28+
return path.join(target, id)
29+
}
30+
}
31+
})
32+
2233
if (quasarConf.ctx.prod === true) {
2334
cfg.build.outDir = appPaths.resolve.capacitor('www')
2435
}

app-vite/lib/quasar-config-file.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,17 +430,15 @@ class QuasarConfFile {
430430
__INTLIFY_PROD_DEVTOOLS__: cfg.metaConf.debugging
431431
},
432432

433-
resolve: {
434-
alias: {
435-
src: appPaths.srcDir,
436-
app: appPaths.appDir,
437-
components: appPaths.resolve.src('components'),
438-
layouts: appPaths.resolve.src('layouts'),
439-
pages: appPaths.resolve.src('pages'),
440-
assets: appPaths.resolve.src('assets'),
441-
boot: appPaths.resolve.src('boot'),
442-
stores: appPaths.resolve.src('stores')
443-
}
433+
alias: {
434+
src: appPaths.srcDir,
435+
app: appPaths.appDir,
436+
components: appPaths.resolve.src('components'),
437+
layouts: appPaths.resolve.src('layouts'),
438+
pages: appPaths.resolve.src('pages'),
439+
assets: appPaths.resolve.src('assets'),
440+
boot: appPaths.resolve.src('boot'),
441+
stores: appPaths.resolve.src('stores')
444442
},
445443

446444
vueRouterMode: 'hash',

0 commit comments

Comments
 (0)