Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function html() {
return src('app/*.html')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe($.useref({searchPath: ['.tmp', 'app', '.']}))
.pipe($.if('/\.js$/', $.uglify({compress: {drop_console: true}})))
.pipe($.if('/\.css$/b', $.cssnano({safe: true, autoprefixer: false, discardComments: {removeAll: true}})))
.pipe($.if('/\.html$/', $.htmlmin({
collapseWhitespace: true,
minifyCSS: true,
minifyJS: {compress: {drop_console: true}},
processConditionalComments: true,
removeComments: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
})))
gulp.task('html', ['styles'], () => {
//const assets = $.useref.assets({ searchPath: ['.tmp', 'app', '.'] });
return gulp.src('app/*.html')
.pipe($.if('*.html', fileinclude({ prefix: '@@', basepath: '@root' })))
//.pipe($.if('*.html', $.minifyHtml({ conditionals: true, loose: true })))
//.pipe(assets)
//.pipe($.if('*.js', $.uglify()))
//.pipe($.if('*.css', $.minifyCss({ compatibility: '*' })))
//.pipe(assets.restore())
.pipe($.useref())
.pipe(gulp.dest('dist'));
});
gulp.task('files', () => {
return gulp.src('app/**/*.html')
.pipe(fileinclude({ prefix: '@@', basepath: '@root' }))
.pipe(gulp.dest('.tmp/'));
});
.pipe(tap(function (file) {
let htmlName = path.basename(file.path).replace('.html', '');
gulp.src(_this.module.srcPathTemplateFile)
.pipe(strip.text())
.pipe(fileInclude({prefix: '@@', basepath: '@file', context: {moduleName: _this.module.moduleName, htmlName: htmlName}}))
.pipe(replace('../img', '../../static/images/' + _this.module.moduleName)) //fixme important
.pipe(rename({basename: htmlName, extname: '.html'}))
.pipe(gulp.dest(_this.module.buildOutputPathHtmls));
}
))