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

Restore outputRelativePath functionality #121

Merged
merged 1 commit into from
Aug 26, 2015
Merged

Restore outputRelativePath functionality #121

merged 1 commit into from
Aug 26, 2015

Conversation

dbow
Copy link
Contributor

@dbow dbow commented May 16, 2015

Fix for #95

It looks like the outputRelativePath option was removed in this commit: 29e7ccc

The createFile function before:

function createFile(name, content) {        
  var filePath = path.join(path.relative(basePath, mainPath), name)     
  var isStatic = name.split('.').pop() === 'js' || name.split('.').pop() === 'css'      

  if (options.outputRelativePath && isStatic)       
    filePath = options.outputRelativePath + name;       

  return new gutil.File({       
    path: filePath,     
    contents: new Buffer(content)       
  })        
}

and after

function createFile(name, content) {
  var filePath = path.join(path.relative(basePath, mainPath), name);
  return new gutil.File({
    path: filePath,
    contents: new Buffer(content)
  })
}

I'm not familiar with the overall design/architecture here, but this was my best guess as to how to restore the functionality. The createFile function currently only handles the HTML templates/views, so re-adding the code there would not actually modify the output directory of the asset files.

Based on the description of outputRelativePath ("Relative location to html file for new concatenated js and css."), it seemed the best place for the value was in the name property of the blocks, which is passed as the first argument to gulp-concat here.

If someone who is familiar with the repo could take a look and review that'd be great! I could write some tests, though a lot of the tests were failing locally for me already so not sure how maintained the tests are? (or if that was some issue with my local setup).

Also, there is already a PR regarding outputRelativePath here but it modifies the old behavior before that refactor commit above. It looks like there were unanswered questions as to how exactly outputRelativePath should work that are probably worth addressing.

@trevcor
Copy link

trevcor commented Jun 3, 2015

This fix helps me immensely. Any reason why this is taking so long to get merged?

@linyuliang
Copy link

I add a dealOutputFilePath option use to custom outputpath
for example:
gulp.src(file).pipe(usemin({
assetsDir : webappDir,
css : [ 'concat', minifyCss(), rev() ],
js : [ 'concat', uglify({}), rev() ],
html : [ minifyHtml({
empty : true
}) ],
dealFilePath : function(filePath) {
return filePath.replace("{{path}}", "");
},
enableHtmlComment : false,
dealOutputFilePath : function(outputPath) {
var relativePath = hbsUnderWebappPath + location;
var num = (relativePath.split('/')).length - 1;
return new Array(num).join("../") + outputPath.replace("{{path}}", "");
},
})).pipe(gulp.dest(handlebarOutDir + location));

@seminull
Copy link

restore this option please.

@grayghostvisuals
Copy link
Contributor

@dbow So this fixes the problem with sub dirs files?

zont added a commit that referenced this pull request Aug 26, 2015
Restore outputRelativePath functionality
@zont zont merged commit 70e659d into zont:master Aug 26, 2015
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

Successfully merging this pull request may close these issues.

6 participants