@@ -11,7 +11,7 @@ const gulpif = require('gulp-if');
11
11
const less = require ( 'gulp-less' ) ;
12
12
const util = require ( path . join ( __dirname , './lib/util' ) ) ;
13
13
const uglify = require ( 'gulp-uglify' ) ;
14
- const usemin = require ( 'gulp-usemin ' ) ;
14
+ const useref = require ( 'gulp-useref ' ) ;
15
15
const lazyImageCSS = require ( 'gulp-lazyimagecss' ) ; // 自动为图片样式添加 宽/高/background-size 属性
16
16
const minifyCSS = require ( 'gulp-cssnano' ) ;
17
17
const imagemin = require ( 'weflow-imagemin' ) ;
@@ -26,6 +26,16 @@ const posthtmlPx2rem = require('posthtml-px2rem');
26
26
const RevAll = require ( 'weflow-rev-all' ) ; // reversion
27
27
const revDel = require ( 'gulp-rev-delete-original' ) ;
28
28
const sass = require ( 'gulp-sass' ) ;
29
+
30
+ //svg转换用到的组件
31
+ var rename = require ( 'gulp-rename' ) ;
32
+ var svgmin = require ( 'gulp-svgmin' ) ;
33
+ var svgInline = require ( 'gulp-svg-inline' ) ;
34
+ var replace = require ( 'gulp-replace' ) ;
35
+ var parseSVG = require ( './common/parseSVG' ) ;
36
+ var svgToPng = require ( './common/svgToPng' ) ;
37
+ var svgSymbol = require ( 'gulp-svg-sprite' ) ;
38
+
29
39
const Common = require ( path . join ( __dirname , '../common' ) ) ;
30
40
31
41
let webp = require ( path . join ( __dirname , './common/webp' ) ) ;
@@ -82,7 +92,10 @@ function dist(projectPath, log, callback) {
82
92
html : path . join ( projectPath , './tmp/html' ) ,
83
93
js : path . join ( projectPath , './tmp/js' ) ,
84
94
sprite : path . join ( projectPath , './tmp/sprite' ) ,
85
- spriteAll : path . join ( projectPath , './tmp/sprite/**/*' )
95
+ spriteAll : path . join ( projectPath , './tmp/sprite/**/*' ) ,
96
+ svg : path . join ( projectPath , './tmp/img' ) ,
97
+ symboltemp : path . join ( projectPath , './tmp/symboltemp/' ) ,
98
+ symbol : path . join ( projectPath , './tmp/symbolsvg' )
86
99
} ,
87
100
dist : {
88
101
dir : path . join ( projectPath , './dist' ) ,
@@ -100,6 +113,11 @@ function dist(projectPath, log, callback) {
100
113
} )
101
114
}
102
115
116
+ // 清除 svg 过渡目录
117
+ function delSVG ( ) {
118
+ return del ( [ paths . tmp . symboltemp ] ) ;
119
+ }
120
+
103
121
function condition ( file ) {
104
122
return path . extname ( file . path ) === '.png' ;
105
123
}
@@ -112,7 +130,7 @@ function dist(projectPath, log, callback) {
112
130
console . log ( error . message ) ;
113
131
log ( error . message ) ;
114
132
} )
115
- . pipe ( lazyImageCSS ( { imagePath : lazyDir } ) )
133
+ . pipe ( lazyImageCSS ( { imagePath : lazyDir , SVGGracefulDegradation : config . SVGGracefulDegradation } ) )
116
134
. pipe ( tmtsprite ( { margin : 4 } ) )
117
135
. pipe ( gulpif ( condition , gulp . dest ( paths . tmp . sprite ) , gulp . dest ( paths . tmp . css ) ) )
118
136
. on ( 'data' , function ( ) {
@@ -239,7 +257,7 @@ function dist(projectPath, log, callback) {
239
257
) )
240
258
)
241
259
. pipe ( gulp . dest ( paths . tmp . html ) )
242
- . pipe ( usemin ( ) )
260
+ . pipe ( useref ( ) )
243
261
. pipe ( gulp . dest ( paths . tmp . html ) )
244
262
. on ( 'end' , function ( ) {
245
263
console . log ( 'compileHtml success.' ) ;
0 commit comments