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

feat: allow manually specifying whether server-rendering is targeted #1764

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface VueLoaderOptions {
hotReload?: boolean
exposeFilename?: boolean
appendExtension?: boolean

isServerBuild?: boolean
}

let errorEmitted = false
Expand Down Expand Up @@ -85,7 +87,7 @@ export default function loader(
const options = (loaderUtils.getOptions(loaderContext) ||
{}) as VueLoaderOptions

const isServer = target === 'node'
const isServer = options.isServerBuild ?? target === 'node'
const isProduction = mode === 'production'

const { descriptor, errors } = parse(source, {
Expand Down
2 changes: 1 addition & 1 deletion src/resolveScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function resolveScript(
}

const isProd = loaderContext.mode === 'production'
const isServer = loaderContext.target === 'node'
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
const enableInline = canInlineTemplate(descriptor, isProd)

const cacheToUse = isServer ? serverCache : clientCache
Expand Down
2 changes: 1 addition & 1 deletion src/templateLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
const options = (loaderUtils.getOptions(loaderContext) ||
{}) as VueLoaderOptions

const isServer = loaderContext.target === 'node'
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
const isProd = loaderContext.mode === 'production'
const query = qs.parse(loaderContext.resourceQuery.slice(1))
const scopeId = query.id as string
Expand Down