Commit f0beed32 authored by Evan You's avatar Evan You

fix: hide ext appending behind a flag (ref #1372)

parent 5a7d56d7
...@@ -72,7 +72,12 @@ module.exports = function (source) { ...@@ -72,7 +72,12 @@ module.exports = function (source) {
// e.g. foo.vue?type=template&id=xxxxx // e.g. foo.vue?type=template&id=xxxxx
// and we will return early // and we will return early
if (incomingQuery.type) { if (incomingQuery.type) {
return selectBlock(descriptor, loaderContext, incomingQuery) return selectBlock(
descriptor,
loaderContext,
incomingQuery,
!!options.appendExtension
)
} }
// module id for scoped CSS & hot-reload // module id for scoped CSS & hot-reload
......
module.exports = function selectBlock (descriptor, loaderContext, query) { module.exports = function selectBlock (
descriptor,
loaderContext,
query,
appendExtension
) {
// template // template
if (query.type === `template`) { if (query.type === `template`) {
loaderContext.resourcePath += '.' + (descriptor.template.lang || 'html') if (appendExtension) {
loaderContext.resourcePath += '.' + (descriptor.template.lang || 'html')
}
loaderContext.callback( loaderContext.callback(
null, null,
descriptor.template.content, descriptor.template.content,
...@@ -12,7 +19,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) { ...@@ -12,7 +19,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) {
// script // script
if (query.type === `script`) { if (query.type === `script`) {
loaderContext.resourcePath += '.' + (descriptor.script.lang || 'js') if (appendExtension) {
loaderContext.resourcePath += '.' + (descriptor.script.lang || 'js')
}
loaderContext.callback( loaderContext.callback(
null, null,
descriptor.script.content, descriptor.script.content,
...@@ -24,7 +33,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) { ...@@ -24,7 +33,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) {
// styles // styles
if (query.type === `style` && query.index != null) { if (query.type === `style` && query.index != null) {
const style = descriptor.styles[query.index] const style = descriptor.styles[query.index]
loaderContext.resourcePath += '.' + (style.lang || 'css') if (appendExtension) {
loaderContext.resourcePath += '.' + (style.lang || 'css')
}
loaderContext.callback( loaderContext.callback(
null, null,
style.content, style.content,
......
...@@ -179,6 +179,6 @@ test('CSS Modules', async () => { ...@@ -179,6 +179,6 @@ test('CSS Modules', async () => {
// custom ident // custom ident
await testWithIdent( await testWithIdent(
'[path][name]---[local]---[hash:base64:5]', '[path][name]---[local]---[hash:base64:5]',
/css-modules-vue---red---\w{5}/ /css-modules---red---\w{5}/
) )
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment