Skip to content

Commit 821a3a3

Browse files
committed
fix: pick up production env in thread-loader context
fix vuejs/core#3921
1 parent 5f41112 commit 821a3a3

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export default function loader(
8989
{}) as VueLoaderOptions
9090

9191
const isServer = options.isServerBuild ?? target === 'node'
92-
const isProduction = mode === 'production'
92+
const isProduction =
93+
mode === 'production' || process.env.NODE_ENV === 'production'
9394

9495
const filename = resourcePath.replace(/\?.*$/, '')
9596
const { descriptor, errors } = parse(source, {

src/resolveScript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export function resolveScript(
3232
return null
3333
}
3434

35-
const isProd = loaderContext.mode === 'production'
35+
const isProd =
36+
loaderContext.mode === 'production' || process.env.NODE_ENV === 'production'
3637
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
3738
const enableInline = canInlineTemplate(descriptor, isProd)
3839

src/stylePostLoader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const StylePostLoader: webpack.loader.Loader = function (source, inMap) {
1414
map: inMap,
1515
scoped: !!query.scoped,
1616
trim: true,
17-
isProd: this.mode === 'production',
17+
isProd: this.mode === 'production' || process.env.NODE_ENV === 'production',
1818
})
1919

2020
if (errors.length) {

src/templateLoader.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
2121
{}) as VueLoaderOptions
2222

2323
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
24-
const isProd = loaderContext.mode === 'production'
24+
const isProd =
25+
loaderContext.mode === 'production' || process.env.NODE_ENV === 'production'
2526
const query = qs.parse(loaderContext.resourceQuery.slice(1))
2627
const scopeId = query.id as string
2728
const descriptor = getDescriptor(loaderContext.resourcePath)

0 commit comments

Comments
 (0)