File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ var hasBuble = !!tryRequire('buble-loader')
24
24
25
25
// for mp js
26
26
var { compileMP, compileMPScript } = require ( './mp-compiler' )
27
+ var { defaultStylePart } = require ( './mp-compiler/util' )
27
28
28
29
var rewriterInjectRE = / \b ( c s s (?: - l o a d e r ) ? (?: \? [ ^ ! ] + ) ? ) (?: ! | $ ) /
29
30
@@ -99,6 +100,12 @@ module.exports = function (content) {
99
100
100
101
var output = ''
101
102
var parts = parse ( content , fileName , this . sourceMap )
103
+
104
+ // fix #153: 根组件没有 style 模块,不生成页面的 wxss,补齐内容方便加载 vendor.wxss
105
+ if ( ! parts . styles . length ) {
106
+ parts . styles . push ( defaultStylePart )
107
+ }
108
+
102
109
var hasScoped = parts . styles . some ( function ( s ) { return s . scoped } )
103
110
var hasComment = parts . template && parts . template . attrs && parts . template . attrs . comments
104
111
Original file line number Diff line number Diff line change @@ -114,7 +114,23 @@ function getPathPrefix (src) {
114
114
return `${ '../' . repeat ( length ) } `
115
115
}
116
116
117
+ const defaultStylePart = {
118
+ type : 'style' ,
119
+ content : '\n' ,
120
+ start : 0 ,
121
+ attrs : { } ,
122
+ end : 1 ,
123
+ map : {
124
+ version : 3 ,
125
+ sources : [ ] ,
126
+ names : [ ] ,
127
+ mappings : '' ,
128
+ sourcesContent : [ ]
129
+ }
130
+ }
131
+
117
132
module . exports = {
133
+ defaultStylePart,
118
134
cacheFileInfo,
119
135
getFileInfo,
120
136
getCompNameBySrc,
Original file line number Diff line number Diff line change 5
5
var path = require ( 'path' )
6
6
var parse = require ( './parser' )
7
7
var loaderUtils = require ( 'loader-utils' )
8
+ var { defaultStylePart } = require ( './mp-compiler/util' )
8
9
9
10
module . exports = function ( content ) {
10
11
this . cacheable ( )
@@ -16,5 +17,6 @@ module.exports = function (content) {
16
17
if ( Array . isArray ( part ) ) {
17
18
part = part [ query . index ]
18
19
}
20
+ part = part || defaultStylePart
19
21
this . callback ( null , part . content , part . map )
20
22
}
You can’t perform that action at this time.
0 commit comments