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')
2424
2525// for mp js
2626var { compileMP, compileMPScript } = require ( './mp-compiler' )
27+ var { defaultStylePart } = require ( './mp-compiler/util' )
2728
2829var rewriterInjectRE = / \b ( c s s (?: - l o a d e r ) ? (?: \? [ ^ ! ] + ) ? ) (?: ! | $ ) /
2930
@@ -99,6 +100,12 @@ module.exports = function (content) {
99100
100101 var output = ''
101102 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+
102109 var hasScoped = parts . styles . some ( function ( s ) { return s . scoped } )
103110 var hasComment = parts . template && parts . template . attrs && parts . template . attrs . comments
104111
Original file line number Diff line number Diff line change @@ -114,7 +114,23 @@ function getPathPrefix (src) {
114114 return `${ '../' . repeat ( length ) } `
115115}
116116
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+
117132module . exports = {
133+ defaultStylePart,
118134 cacheFileInfo,
119135 getFileInfo,
120136 getCompNameBySrc,
Original file line number Diff line number Diff line change 55var path = require ( 'path' )
66var parse = require ( './parser' )
77var loaderUtils = require ( 'loader-utils' )
8+ var { defaultStylePart } = require ( './mp-compiler/util' )
89
910module . exports = function ( content ) {
1011 this . cacheable ( )
@@ -16,5 +17,6 @@ module.exports = function (content) {
1617 if ( Array . isArray ( part ) ) {
1718 part = part [ query . index ]
1819 }
20+ part = part || defaultStylePart
1921 this . callback ( null , part . content , part . map )
2022}
You can’t perform that action at this time.
0 commit comments