Skip to content

Commit f0beed3

Browse files
committed
fix: hide ext appending behind a flag (ref #1372)
1 parent 5a7d56d commit f0beed3

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

Diff for: lib/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ module.exports = function (source) {
7272
// e.g. foo.vue?type=template&id=xxxxx
7373
// and we will return early
7474
if (incomingQuery.type) {
75-
return selectBlock(descriptor, loaderContext, incomingQuery)
75+
return selectBlock(
76+
descriptor,
77+
loaderContext,
78+
incomingQuery,
79+
!!options.appendExtension
80+
)
7681
}
7782

7883
// module id for scoped CSS & hot-reload

Diff for: lib/select.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
module.exports = function selectBlock (descriptor, loaderContext, query) {
1+
module.exports = function selectBlock (
2+
descriptor,
3+
loaderContext,
4+
query,
5+
appendExtension
6+
) {
27
// template
38
if (query.type === `template`) {
4-
loaderContext.resourcePath += '.' + (descriptor.template.lang || 'html')
9+
if (appendExtension) {
10+
loaderContext.resourcePath += '.' + (descriptor.template.lang || 'html')
11+
}
512
loaderContext.callback(
613
null,
714
descriptor.template.content,
@@ -12,7 +19,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) {
1219

1320
// script
1421
if (query.type === `script`) {
15-
loaderContext.resourcePath += '.' + (descriptor.script.lang || 'js')
22+
if (appendExtension) {
23+
loaderContext.resourcePath += '.' + (descriptor.script.lang || 'js')
24+
}
1625
loaderContext.callback(
1726
null,
1827
descriptor.script.content,
@@ -24,7 +33,9 @@ module.exports = function selectBlock (descriptor, loaderContext, query) {
2433
// styles
2534
if (query.type === `style` && query.index != null) {
2635
const style = descriptor.styles[query.index]
27-
loaderContext.resourcePath += '.' + (style.lang || 'css')
36+
if (appendExtension) {
37+
loaderContext.resourcePath += '.' + (style.lang || 'css')
38+
}
2839
loaderContext.callback(
2940
null,
3041
style.content,

Diff for: test/style.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ test('CSS Modules', async () => {
179179
// custom ident
180180
await testWithIdent(
181181
'[path][name]---[local]---[hash:base64:5]',
182-
/css-modules-vue---red---\w{5}/
182+
/css-modules---red---\w{5}/
183183
)
184184
})

0 commit comments

Comments
 (0)