Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vite-plugin): production builds (fix: #17267) #17272

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions vite-plugin/src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { vueTransform } from './vue-transform.js'
import { createScssTransform } from './scss-transform.js'
import { parseViteRequest, createExtMatcher } from './query.js'
import { mapQuasarImports } from './js-transform.js'
import { viteCheckDevMode } from './vite-check-dev-mode.js'

const defaultOptions = {
runMode: 'web-client',
Expand Down Expand Up @@ -41,8 +42,8 @@ function getConfigPlugin (opts) {
}
},

config (viteConf, { mode }) {
return getViteConfig(opts.runMode, mode, viteConf)
config (viteConf, viteConfEnv) {
return getViteConfig(opts.runMode, viteConfEnv, viteConf)
}
}
}
Expand Down Expand Up @@ -95,7 +96,7 @@ function getScriptTransformsPlugin (opts) {
name: 'vite:quasar:script',

configResolved (resolvedConfig) {
if (opts.devTreeshaking === false && resolvedConfig.mode !== 'production') {
if (opts.devTreeshaking === false && viteCheckDevMode(resolvedConfig)) {
useTreeshaking = false
}
},
Expand Down
3 changes: 3 additions & 0 deletions vite-plugin/src/vite-check-dev-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function viteCheckDevMode ({ command, mode }) {
return command === 'serve' && mode === 'development'
}
5 changes: 3 additions & 2 deletions vite-plugin/src/vite-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { readFileSync } from 'node:fs'
import { join } from 'node:path'

import { quasarPath } from './quasar-path.js'
import { viteCheckDevMode } from './vite-check-dev-mode.js'

const { version } = JSON.parse(
readFileSync(join(quasarPath, 'package.json'), 'utf-8')
)

export function getViteConfig (runMode, viteMode, externalViteCfg) {
export function getViteConfig (runMode, viteCfgEnv, externalViteCfg) {
const viteCfg = {
define: {
__QUASAR_VERSION__: `'${ version }'`,
Expand All @@ -32,7 +33,7 @@ export function getViteConfig (runMode, viteMode, externalViteCfg) {
else {
// Alias "quasar" package to its dev file (which has flags)
// to reduce the number of HTTP requests while in DEV mode
if (viteMode !== 'production') {
if (viteCheckDevMode(viteCfgEnv)) {
viteCfg.resolve = {
alias: [
{ find: /^quasar$/, replacement: 'quasar/dist/quasar.client.js' }
Expand Down