Skip to content

Commit

Permalink
fix: pick up production env in thread-loader context
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 16, 2021
1 parent 5f41112 commit 821a3a3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -89,7 +89,8 @@ export default function loader(
{}) as VueLoaderOptions

const isServer = options.isServerBuild ?? target === 'node'
const isProduction = mode === 'production'
const isProduction =
mode === 'production' || process.env.NODE_ENV === 'production'

const filename = resourcePath.replace(/\?.*$/, '')
const { descriptor, errors } = parse(source, {
Expand Down
3 changes: 2 additions & 1 deletion src/resolveScript.ts
Expand Up @@ -32,7 +32,8 @@ export function resolveScript(
return null
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/stylePostLoader.ts
Expand Up @@ -14,7 +14,7 @@ const StylePostLoader: webpack.loader.Loader = function (source, inMap) {
map: inMap,
scoped: !!query.scoped,
trim: true,
isProd: this.mode === 'production',
isProd: this.mode === 'production' || process.env.NODE_ENV === 'production',
})

if (errors.length) {
Expand Down
3 changes: 2 additions & 1 deletion src/templateLoader.ts
Expand Up @@ -21,7 +21,8 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
{}) as VueLoaderOptions

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

0 comments on commit 821a3a3

Please sign in to comment.