File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Expand file tree Collapse file tree 4 files changed +28
-3
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
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " mpvue-loader" ,
3
- "version" : " 1.0.8 " ,
3
+ "version" : " 1.0.9 " ,
4
4
"description" : " mpvue single-file component loader for Webpack" ,
5
5
"main" : " index.js" ,
6
6
"repository" : {
67
67
},
68
68
"peerDependencies" : {
69
69
"css-loader" : " *" ,
70
- "mpvue-template-compiler" : " ^1.0.6 "
70
+ "mpvue-template-compiler" : " ^1.0.7 "
71
71
},
72
72
"devDependencies" : {
73
73
"babel-core" : " ^6.25.0" ,
90
90
"marked" : " ^0.3.6" ,
91
91
"memory-fs" : " ^0.4.1" ,
92
92
"mkdirp" : " ^0.5.1" ,
93
- "mpvue-template-compiler" : " ^1.0.6 " ,
93
+ "mpvue-template-compiler" : " ^1.0.7 " ,
94
94
"mocha" : " ^3.4.2" ,
95
95
"node-libs-browser" : " ^2.0.0" ,
96
96
"normalize-newline" : " ^3.0.0" ,
You can’t perform that action at this time.
0 commit comments