Search code examples
javascripthtmlgulp

How to copy static html pages in gulp


I am using nunjucks for my project. Now I have one HTML site with its own assets. I need to have it in my path url/static_pages/page.

But if I only copy it in the pages folder, the gulp build does not recognise it.

How can I make a simple gulp task that would copy the files from for example pages/static_pages/ into the /dist folder and have it on my correct path?

Thanks


Solution

  • Here an example a gulp task to copy html pages:

    gulp.html.js

    module.exports.copy = function(){
        var src = [];
            src.push('static_pages/page/*.html');
    
        var dist = 'dist/pages/static_pages';
    
        return gulp.src(src)
            .pipe(gulp.dest(dist));
    
    };
    

    gulpfile.js

    var html = require('gulp.html');
    gulptask('htmlcopy', html.copy);
    

    You need to check your paths on your own. I cannot see if you use the right paths.