File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,18 @@ MpvuePlugin.prototype.apply = function(compiler) {
1616 chunks . reverse ( ) . forEach ( chunk => {
1717 chunk . files . forEach ( childFile => {
1818 if ( path . extname ( childFile ) === extname && compilation . assets [ filePath ] ) {
19- const relativePath = upath . normalize ( relative ( filePath , childFile ) )
20- content = extname === '.wxss' ?
21- `@import "${ relativePath } ";\n${ content } `
22- : `require("${ relativePath } ");\n${ content } ` ;
19+ let relativePath = upath . normalize ( relative ( filePath , childFile ) )
20+
21+ // 百度小程序js引用不支持绝对路径,改为相对路径
22+ if ( extname === '.js' && ! / ^ \. ( \. ) ? \/ / . test ( relativePath ) ) {
23+ relativePath = `./${ relativePath } ` ;
24+ }
25+
26+ if ( / ^ ( \. w x s s ) | ( \. c s s ) $ / . test ( extname ) ) {
27+ content = `@import "${ relativePath } ";\n${ content } ` ;
28+ } else {
29+ content = `require("${ relativePath } ");\n${ content } ` ;
30+ }
2331 }
2432 } )
2533 compilation . assets [ filePath ] . source = ( ) => content ;
You can’t perform that action at this time.
0 commit comments