Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple build paths of HTML template and compiled asset #37

Closed
mzgajner opened this issue Apr 14, 2014 · 5 comments
Closed

Decouple build paths of HTML template and compiled asset #37

mzgajner opened this issue Apr 14, 2014 · 5 comments

Comments

@mzgajner
Copy link

I have a HTML template file placed in a random internal location (wherever the framework decides it stores templates). My publicly visible web folder is stored elsewhere.

Because of this structure, I have a few problems to overcome. In the template, I define blocks normally:

<!-- build:js js/lib.js -->

The path in this block is the path I want to appear in the processed HTML file, but gulp-usemin assumes that the processed JS file should also be stored according to this path, relative to my HTML template. This is not the case.

To give a more literal example, these steps are needed:

  • a template in /project-source/templates/dev/template.html needs to compile to /project-source/templates/prod/template.html
  • JS assets in /public-html/uncompiled-js/*.js need to compile to /public-html/js/compiled.js
  • reference in the compiled template needs to point to /js/compiled.js

I think this a pretty common use case, since frameworks can often store their templates somewhere different than the static JS/CSS files. Is there a way to configure gulp-usemin to achieve what I want?

@zont
Copy link
Owner

zont commented Apr 14, 2014

Maybe you need alternate search path?

<!-- build:<pipelineId>(alternate search path) <path> -->

@mzgajner
Copy link
Author

Yes, tried that, but that only affects input, where it looks for files, so I can define:

<!-- build:js(/public-html/uncompiled-js/) /js/compiled.js -->

And it will correctly find the uncompiled JS files, but the compiled file will still be stored to /some-path-where-template-is-compiled/js/compiled.js. I cannot separately define where to store compiled template and where to store compiled JS.

@zont
Copy link
Owner

zont commented Apr 14, 2014

Maybe:

var gulpFilter = require('gulp-filter');
var jsFilter = gulpFilter('**/*.js');

 gulp.src('./*.html')
    .pipe(usemin({...}))
    .pipe(jsFilter)
    .pipe(gulp.dest('folder_for_js/'));
    .pipe(jsFilter.restore())
    .pipe(gulp.dest('build/'));

@mzgajner
Copy link
Author

Looks promising, thanks!

@zont zont closed this as completed Apr 14, 2014
@dgwaldo
Copy link

dgwaldo commented Nov 19, 2015

@mzgajner Just made this branch for use in a build process at work, added ability decouple bundle and build path, as well as ability to add an async tag. https://github.com/dgwaldo/gulp-usemin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants