Gulp Useref Nested Directories -
i'm gulp novice directory structure this:
.tmp │   file001.html │   file002.html |   ... │ |───js |   │   file1.js |   │   file2.js └───css     │   file1.css     │   file2.css     |     └───folder1     │   file011.html     │   file012.html     │     ├───subfolder1     │   │   file111.html     │   │   file112.html     │   │   ...     │     └───folder2     │   file021.html     │   file022.html     | here useref task
gulp.task('useref', function() {  return gulp.src('.tmp/**/*.html') .pipe(useref()) .pipe(gulpif('*.js', uglify())) .pipe(gulpif('*.css', cssnano())) .pipe(gulp.dest('dist')); }); and here html
<!--build:css /css/styles.min.css--> <link rel="stylesheet" href="/css/file1.css"> <link rel="stylesheet" href="/css/file2.css"> <!--endbuild-->  <!--build:js /js/main.min.js --> <script src="/js/file1.js"></script> <script src="/js/file2.js"></script> <!-- endbuild --> what want have useref grab assets in html files within .tmp, directory (including in subdirectories) , recreate directory structure within dist directory.
i uglified , minified files expected in dist root, multiple errors such this:
error: file not found singular glob: .tmp/folder1/subfolder1/js/file1.js
the file not found because, can see, path wrong (should .tmp/js/file1.js). also, subdirectories not created in dist.
i've tried understand why happening , can correct it, after hours of trying, i'm turning here help. in advance.
i found plugin accomplishes need. https://docs.omniref.com/js/npm/gulp-use-asset/0.1.1 same thing useref, maintains directory structure when files copied dist.
Comments
Post a Comment