File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed
packages/webpack/src/config Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ export default class WebpackBaseConfig {
38
38
isDev : this . dev ,
39
39
isServer : this . isServer ,
40
40
isClient : ! this . isServer ,
41
- isModern : Boolean ( this . isModern )
41
+ isModern : Boolean ( this . isModern ) ,
42
+ isLegacy : Boolean ( ! this . isModern )
42
43
}
43
44
}
44
45
@@ -57,10 +58,13 @@ export default class WebpackBaseConfig {
57
58
normalizeTranspile ( ) {
58
59
// include SFCs in node_modules
59
60
const items = [ / \. v u e \. j s / i]
60
- for ( const pattern of this . buildContext . buildOptions . transpile ) {
61
+ for ( let pattern of this . buildContext . buildOptions . transpile ) {
62
+ if ( typeof pattern === 'function' ) {
63
+ pattern = pattern ( this . nuxtEnv )
64
+ }
61
65
if ( pattern instanceof RegExp ) {
62
66
items . push ( pattern )
63
- } else {
67
+ } else if ( typeof pattern === 'string' ) {
64
68
const posixModule = pattern . replace ( / \\ / g, '/' )
65
69
items . push ( new RegExp ( escapeRegExp ( path . normalize ( posixModule ) ) ) )
66
70
}
Original file line number Diff line number Diff line change @@ -20,10 +20,13 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
20
20
const whitelist = [
21
21
/ \. (? ! j s ( x | o n ) ? $ ) / i
22
22
]
23
- for ( const pattern of this . buildContext . buildOptions . transpile ) {
23
+ for ( let pattern of this . buildContext . buildOptions . transpile ) {
24
+ if ( typeof pattern === 'function' ) {
25
+ pattern = pattern ( this . nuxtEnv )
26
+ }
24
27
if ( pattern instanceof RegExp ) {
25
28
whitelist . push ( pattern )
26
- } else {
29
+ } else if ( typeof pattern === 'string' ) {
27
30
const posixModule = pattern . replace ( / \\ / g, '/' )
28
31
whitelist . push ( new RegExp ( escapeRegExp ( posixModule ) ) )
29
32
}
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ describe('basic dev', () => {
30
30
'@scoped/packageA' ,
31
31
'@scoped\\packageB' ,
32
32
'vue.test.js' ,
33
- / v u e - t e s t /
33
+ / v u e - t e s t / ,
34
+ ( { isModern } ) => isModern ? 'modern-test' : 'normal-test'
34
35
] ,
35
36
loaders : {
36
37
cssModules : {
@@ -77,6 +78,7 @@ describe('basic dev', () => {
77
78
expect ( transpile ( path . normalize ( 'node_modules/test.vue.js' ) ) ) . toBe ( true )
78
79
expect ( transpile ( path . normalize ( 'node_modules/@scoped/packageA/src/index.js' ) ) ) . toBe ( true )
79
80
expect ( transpile ( path . normalize ( 'node_modules/@scoped/packageB/src/index.js' ) ) ) . toBe ( true )
81
+ expect ( transpile ( path . normalize ( 'node_modules/normal-test' ) ) ) . toBe ( true )
80
82
} )
81
83
82
84
test ( 'Config: build.filenames' , ( ) => {
You can’t perform that action at this time.
0 commit comments